Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/example.py
blob: 2cf3211a986ca267a9628d0b6ab8446c4cc1a21a (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
#!/usr/bin/python
import gtk
import gobject
from ConfigParser import SafeConfigParser
from subprocess import Popen

class MyApp():

    def __init__(self):
    
        parser = SafeConfigParser()
        parser.read('config.ini')
        
        window = gtk.Window()
        vbox = gtk.VBox()
        hbox = gtk.HBox()
        label = gtk.Label()

        window.connect('destroy', self.destroy)

        window.add(vbox)
        vbox.add(label)
        vbox.add(hbox)
       
        label.set_label(parser.get('mama', 'palabra'))
        button1 = gtk.Button()
        button2 = gtk.Button()
        button3 = gtk.Button()
        button1.set_label(parser.get('mama', 'op1'))
        button2.set_label(parser.get('mama', 'op2'))
        button3.set_label(parser.get('mama', 'op3'))
        
        hbox.add(button1)
        hbox.add(button2)
        hbox.add(button3)
        
        text = parser.get('mama', 'silaba')
        datac = parser.get('mama', 'opc')
        button1.connect('clicked', self.__button_clicked_cb, 'op1', datac)
        button2.connect('clicked', self.__button_clicked_cb, 'op2', datac)
        button3.connect('clicked', self.__button_clicked_cb, 'op3', datac)

        window.show_all()
           

    def destroy(self, window, data=None):
        gtk.main_quit()
    
    def say(text):
        Popen(['espeak', '-v', 'es', text])  
    
    def hablar():
        say('Hola tch')         
    
    def __button_clicked_cb(self, button, data=None, opc=None):
        if data == opc:
             print "OPCION CORRECTA"
             hablar()
        else :
            print "OPCION INCORRECTA"
            
        
            
if __name__ == "__main__":
    my_app = MyApp()
    gtk.main()