Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/prueba.py
blob: 2a564619f615212f022703b584140d28205b78a0 (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
#!/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 patrones(self):
        parser=SafeConfigParser()
        parser.read('config.ini')
        words= parser.get('patron1','patron')
        #words=['arriba','abajo','izquierda','derecha']
        random.shuffle(words)
        n=0;m=10
        for i in words: 
            self.say(i[n:m])
            n+=1
            m+=1
               
       
        
        
    def cargar_ui(self):
        window = gtk.Window()
        vbox = gtk.VBox()
        hbox = gtk.HBox()
        label = gtk.Label()
        window.connect('destroy', self.destroy)
        window.connect('key-press-event', self.__key_press_cb, label)
        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)
        
        window.show_all()
        
                 
    def destroy(self, window, data=None):
        gtk.main_quit()
        
            
    def __key_press_cb(self, window, event, label):
        key_name = gtk.gdk.keyval_name(event.keyval)
        if (key_name=='Up'):
            self.say ('Arriba')
        elif (key_name=='Down'):
            self.say ('Abajo')
        elif (key_name=='Left'):
            self.say ('Izquierda')
        elif (key_name=='Right'):
            self.say ('Derecha')
        elif (key_name=='space'):
            self.patrones()
        else:
            self.say('Tecla incorrecta')
                       
    def say(self, text):
        Popen(['espeak', '-v', 'es', text])
        
           
if __name__ == "__main__":
    my_app = MyApp()
    gtk.main()