Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/008-gtk-connect/example.py
blob: c6dbcb947d8534402510ebc4a1450a0d66ea2acb (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
#!/usr/bin/python
import gtk


class MyApp():

    def __init__(self):
        window = gtk.Window()
        vbox = gtk.VBox()
        self.entry = gtk.Entry()
        hbox = gtk.HBox()
        button_right = gtk.Button()
        button_left = gtk.Button()

        window.connect('destroy', self.destroy)
        button_right.connect('clicked', self.__button_clicked_cb, 'Right!')
        button_left.connect('clicked', self.__button_clicked_cb, 'Left!')

        window.add(vbox)
        vbox.add(self.entry)
        vbox.add(hbox)
        hbox.add(button_left)
        hbox.add(button_right)

        window.show()
        vbox.show()
        self.entry.show()
        hbox.show()
        button_right.show()
        button_left.show()

    def destroy(self, window, data=None):
        gtk.main_quit()

    def __button_clicked_cb(self, button, data=None):
        self.entry.set_text(data)

if __name__ == "__main__":
    my_app = MyApp()
    gtk.main()