Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/prueba.py
blob: 76fa63d893684cf418e35d2af8d819c900fb78e8 (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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/usr/bin/python
import gtk
import gobject
import random
from ConfigParser import SafeConfigParser
from subprocess import Popen


class MyApp():

    def __init__(self):
       self.load_data()
       self.cargar_ui()
                  
    def load_data(self):
        parser=SafeConfigParser()
        parser.read('config.ini')
        words= parser.get('inicio','patron')
        self.say (words)    
     
    # def __key_press_cb_capture(self, window, event, label):
     #   self.say('Ingrese por teclado los patrones que has escuchado')
      #  self.key_name = gtk.gdk.keyval_name(event.keyval)
       # if (self.key_name=='Up'):
        #    self.say ('Arriba')
         #   self.key_name='arriba'
        #elif (self.key_name=='Down'):
         #   self.say ('Abajo')
          #  self.key_name='abajo'
        #elif (self.key_name=='Left'):
         #   self.say ('Izquierda')
          #  self.key_name='izquierda'
        #elif (self.key_name=='Right'):
         #   self.say ('Derecha')
          #  self.key_name='derecha'
        #if(self.key_name==patr
        
          
   
     #def controlar_patrones():
      #  for i in range(4):
       #     if (self.patron[i]==self.key_name):
        #        self.say('Correcto')
         #   else:
          #      self.say('Incorrecto. Vuelva a intentarlo desde el inicio')
           #     controlar_patrones()
                
        #self.say('Felicidades, has acertado totalmente. Aprieta espacio para generar un nuevo patron')
                    
        
    def leer_patrones(self):
        self.say(self.p)
        #self.controlar_patrones()    
        
    def generar_patrones(self):
        self.patron=['arriba','abajo','izquierda', 'derecha']
        random.shuffle(self.patron)
        self.p="    ".join(self.patron)
        self.hbox.clear()
        image=gtk.Image()
        image.set_from_file('imagenes/'+patron[0]+'.png')
        image.show()
        self.hbox.pack_start(image)
            
        image=gtk.Image()
        image.set_from_file('imagenes/'+patron[1]+'.png')
        image.show()
        self.hbox.pack_start(image)
            
        image=gtk.Image()
        image.set_from_file('imagenes/'+patron[2]+'.png')
        image.show()
        self.hbox.pack_start(image)
            
        image=gtk.Image()
        image.set_from_file('imagenes/'+patron[3]+'.png')
        image.show()
        self.hbox.pack_start(image)
        self.leer_patrones()
      
        
    def cargar_ui(self):
        self.window = gtk.Window()
        vbox = gtk.VBox()
        hbox = gtk.HBox()
        label = gtk.Label()
        self.window.connect('destroy', self.destroy)
        self.window.connect('key-press-event', self.__key_press_cb, label)
        self.window.add(vbox)
    
        vbox.add(hbox)
        
        image=gtk.Image()
        image.set_from_file('imagenes/derecha.png')
        image.show()
        hbox.pack_start(image)
        
        image=gtk.Image()
        image.set_from_file('imagenes/izquierda.png')
        image.show()
        hbox.pack_start(image)
        
        image=gtk.Image()
        image.set_from_file('imagenes/arriba.png')
        image.show()
        hbox.pack_start(image)
        
        image=gtk.Image()
        image.set_from_file('imagenes/abajo.png')
        image.show()
        hbox.pack_start(image)
        
        self.window.show_all()
        
                 
    def destroy(self, window, data=None):
        gtk.main_quit()
        
            
    def __key_press_cb(self, window, event, label):
        self.key_name = gtk.gdk.keyval_name(event.keyval)
        if (self.key_name=='Up'):
            self.say ('Arriba')
            self.key_name='arriba'
        elif (self.key_name=='Down'):
            self.say ('Abajo')
            self.key_name='abajo'
        elif (self.key_name=='Left'):
            self.say ('Izquierda')
            self.key_name='izquierda'
        elif (self.key_name=='Right'):
            self.say ('Derecha')
            self.key_name='derecha'
        elif (self.key_name=='space'):
            self.generar_patrones()
        else:
            self.say('Tecla incorrecta')
                       
    def say(self, text):
        Popen(['espeak', '-v', 'es', text])
        
           
if __name__ == "__main__":
    my_app = MyApp()
    gtk.main()