Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/imagen.py
blob: bbce6ab195dd170708896fa43dcfaa0566042dba (plain)
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/python
# -*- encoding: utf-8 -*-
import gtk
import programa
import voice

label_opciones = ["Claro - Oscuro", "Joven - Anciano", "Gordo - Flaco", "Alto - Bajo", "Pequeño - Grande", "Feliz - Triste"]
listImagenes = ['gordo.jpg', 'flaco.jpg','alto.jpg', 'bajo.jpg']
correct_option = [label_opciones[2], "Alto - Bajo"]

class MyApp():
    def __init__(self):
	self.indice_opciones = 0
	self.indice_imagen = 0
	self.indice_resp_correcta = 0

        window = gtk.Window()
        vbox = gtk.VBox()
        hbox = gtk.HBox()

	window.connect('destroy', self.destroy)
        window.add(vbox)
        window.set_title('Piensa y Escribe')
        #window.set_default_size(100,100)
	window.set_size_request(700,600)
        window.set_position(gtk.WIN_POS_CENTER)
        vbox.add(hbox)

	imagen1 = gtk.Image() 
	imagen2 = gtk.Image()
	button1 = gtk.Button()
	button2 = gtk.Button()
	button3 = gtk.Button()

	imagen1.set_from_file(listImagenes[self.indice_imagen])
	self.indice_imagen += 1
	imagen2.set_from_file(listImagenes[self.indice_imagen])
	self.indice_imagen += 1
	
	button1.set_label(label_opciones[self.indice_opciones])
	self.indice_opciones += 1
	button2.set_label(label_opciones[self.indice_opciones])
	self.indice_opciones += 1
	button3.set_label(label_opciones[self.indice_opciones])
	self.indice_opciones += 1
	
	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[self.indice_resp_correcta], imagen1,
								imagen2, button1, button2, button3)
	button2.connect('clicked', self.__correcto_cb, correct_option[self.indice_resp_correcta], imagen1,
								imagen2, button1, button2, button3)
	button3.connect('clicked', self.__correcto_cb, correct_option[self.indice_resp_correcta], imagen1,
								imagen2, button1, button2, button3)

	#print correct_option[self.indice_resp_correcta]

	hbox.add(imagen1)
	hbox.add(imagen2)
	vbox.add(button1)
	vbox.add(button2)
	vbox.add(button3)
	window.show_all()

    def resetear(self, imagen1, imagen2, button1, button2, button3):
	imagen1.set_from_file(listImagenes[self.indice_imagen])
	self.indice_imagen += 1
	imagen2.set_from_file(listImagenes[self.indice_imagen])
	self.indice_imagen += 1
	
	button1.set_label(label_opciones[self.indice_opciones])
	self.indice_opciones += 1
	button2.set_label(label_opciones[self.indice_opciones])
	self.indice_opciones += 1
	button3.set_label(label_opciones[self.indice_opciones])
	self.indice_opciones += 1
	print self.indice_resp_correcta
	self.indice_resp_correcta += 1
	print self.indice_resp_correcta

    def __correcto_cb(self, button, clave, imagen1, imagen2, button1, button2, button3):
	if  button.get_label() == clave:
		#print clave
		voice.say('Opcion correcta')
		#self.indice_resp_correcta += 1
		self.resetear(imagen1, imagen2, button1, button2, button3)
		print self.indice_resp_correcta
	else:
		print clave
		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()