Philipp Schrader | 7520ee6 | 2022-12-10 14:04:40 -0800 | [diff] [blame^] | 1 | # This is the extended example from |
| 2 | # https://python-gtk-3-tutorial.readthedocs.io/en/latest/introduction.html#extended-example |
| 3 | |
| 4 | import gi |
| 5 | |
| 6 | gi.require_version("Gtk", "3.0") |
| 7 | from gi.repository import Gtk |
| 8 | |
| 9 | |
| 10 | class MyWindow(Gtk.Window): |
| 11 | |
| 12 | def __init__(self): |
| 13 | super().__init__(title="Hello World") |
| 14 | |
| 15 | self.button = Gtk.Button(label="Click Here") |
| 16 | self.button.connect("clicked", self.on_button_clicked) |
| 17 | self.add(self.button) |
| 18 | |
| 19 | def on_button_clicked(self, widget): |
| 20 | print("Hello World") |
| 21 | |
| 22 | |
| 23 | win = MyWindow() |
| 24 | win.connect("destroy", Gtk.main_quit) |
| 25 | win.show_all() |
| 26 | Gtk.main() |