| 1 | #!/usr/bin/env python |
| 2 | #GTK Hello world! by Harvie 2oo9 |
| 3 | |
| 4 | import gtk |
| 5 | |
| 6 | class Hello: |
| 7 | |
| 8 | def on_window1_destroy(self, widget, data=None): |
| 9 | gtk.main_quit() |
| 10 | |
| 11 | def on_button1_clicked(self, widget, data=None): |
| 12 | self.button1.set_label(self.entry1.get_text()) |
| 13 | print(self.entry1.get_text()) |
| 14 | |
| 15 | def __init__(self): |
| 16 | builder = gtk.Builder() |
| 17 | builder.add_from_file("hello.ui") |
| 18 | |
| 19 | self.window1 = builder.get_object("window1") |
| 20 | self.button1 = builder.get_object("button1") |
| 21 | self.entry1 = builder.get_object("entry1") |
| 22 | builder.connect_signals(self) |
| 23 | |
| 24 | self.window1.show() |
| 25 | |
| 26 | if __name__ == "__main__": |
| 27 | main = Hello() |
| 28 | gtk.main() |