1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
#!/usr/bin/python
import gtk
import gobject
import random
from ConfigParser import SafeConfigParser
from subprocess import Popen
class MyApp():
def __init__(self,puntaje=0,numero=1):
self.puntaje=puntaje
self.numero=numero
Popen(['espeak', '-v', 'es', 'Como se escribe la palabra cubo????'])
image = gtk.Image()
#image = gtk.image_new_from_pixbuf(gtk.gdk.pixbuf_new_from_file_at_size('imagenes/cubo.jpg', 100, 100))
image.set_from_file('imagenes/cubo.jpg')
window = gtk.Window()
window.set_position(gtk.WIN_POS_CENTER)
window.set_border_width(200)
window.set_title('ELEGIR')
vbox = gtk.VBox()
hbox = gtk.HBox()
button_1 = gtk.Button("cubo")
button_2 = gtk.Button("cuvo")
button_3 = gtk.Button("kubo")
window.connect('destroy', self.destroy)
button_1.connect('clicked',self.cambio, button_2,button_3,image,1)
button_2.connect('clicked',self.cambio, button_1,button_3,image,0)
button_3.connect('clicked',self.cambio, button_1,button_2,image,0)
window.add(vbox)
vbox.add(image)
vbox.add(hbox)
hbox.add(button_1)
hbox.add(button_2)
hbox.add(button_3)
window.show()
vbox.show()
image.show()
hbox.show()
button_1.show()
button_2.show()
button_3.show()
def cambio(self,b,b2=None,b3=None,i=None,p=0):
parser = SafeConfigParser()
parser.read('config.ini')
if b.get_label()== parser.get('pregunta'+str(self.numero), 'correcta'):
text ='Felicidades, elegiste la respuesta correcta!!!'
print 'Felicidades, elegiste la respuesta correcta!!!'
else:
text ='La palabra seleccionada, no es la correcta'
print 'Felicidades, elegiste la respuesta correcta!!!'
self.puntaje=self.puntaje +p
text=text + ' tu puntajes adicional es : ' + str(p)
Popen(['espeak', '-v', 'es', text])
# parser = SafeConfigParser()
# NECESITO UNA PAUSA ANTES DE CAMBIAR LA FIGURA
self.numero=random.randint(1,4)# pregunta seleccionada al azar
#i = gtk.image_new_from_pixbuf(gtk.gdk.pixbuf_new_from_file_at_size(parser.get('pregunta'+str(self.numero), 'imagen'), 100, 100))
i.set_from_file(parser.get('pregunta'+str(self.numero), 'imagen'))
b3.set_label(parser.get('pregunta'+str(self.numero), 'correcta'))
b.set_label(parser.get('pregunta'+str(self.numero), 'incorrecta1'))
b2.set_label(parser.get('pregunta'+str(self.numero), 'incorrecta2'))
def say(self,b,text):
Popen(['espeak', '-v', 'es', text])
def destroy(self, window, data=None):
gtk.main_quit()
if __name__ == "__main__":
my_app = MyApp()
gtk.main()
|