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
|
#!/usr/bin/python
import gtk
import programa
import voice
#global columna
#columna = 0
class MyApp():
def __init__(self):
label1 = ['Claro - Oscuro', 'Joven - Anciano', 'Gordo y Flaco']
label2 = ['Nene - Nena', 'Mucho - Poco', 'Fuego - Agua']
myListLabel = [label1, label2]
myImagenes = ['gordo.jpg', 'flaco.jpg']
myListImagenes = [myImagenes]
correct_option = [3, 2]
fila_label = 0
#fila_option = 0
#cantidad_imagenes = 2
image_number = 0
window = gtk.Window()
vbox = gtk.VBox()
hbox = gtk.HBox()
imagen1 = gtk.Image()
imagen1.set_from_file(myListImagenes[image_number][0])
imagen2 = gtk.Image()
imagen2.set_from_file(myListImagenes[image_number][1])
window.connect('destroy', self.destroy)
button1 = gtk.Button()
button1.set_label(myListLabel[fila_label][0])
button2 = gtk.Button()
button2.set_label(myListLabel[fila_label][1])
button3 = gtk.Button()
button3.set_label(myListLabel[fila_label][2])
button1.connect('enter', self.__sobre_boton_cb)
button2.connect('enter', self.__sobre_boton_cb)
button3.connect('enter', self.__sobre_boton_cb)
button1.connect('clicked', self.__correcto_cb, correct_option[0], 1)
button2.connect('clicked', self.__correcto_cb, correct_option[0], 2)
button3.connect('clicked', self.__correcto_cb, correct_option[0], 3)
window.add(vbox)
window.set_title('Piensa y Escribe')
window.set_default_size(100,100)
window.set_position(gtk.WIN_POS_CENTER)
hbox.add(imagen1)
hbox.add(imagen2)
vbox.add(hbox)
vbox.add(button1)
vbox.add(button2)
vbox.add(button3)
window.show_all()
def __correcto_cb(self, button, correct_option, clave):
if correct_option == clave:
voice.say('opcion - correcta')
else:
voice.say('opcion - incorrecta')
def destroy(self, window, data=None):
gtk.main_quit()
def __sobre_boton_cb(self, button):
voice.say(button.get_label())
if __name__ == "__main__":
my_app = MyApp()
gtk.main()
|