awesome-project.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/usr/bin/python
  2. from gi.repository import Gtk
  3. class MyWindow (Gtk.Window):
  4. def __init__(self):
  5. Gtk.Window.__init__(self, title="Hello World!")
  6. self.button = Gtk.Button(label="Click Here!")
  7. self.button.connect("clicked", self.on_button_clicked)
  8. self.add(self.button)
  9. def on_button_clicked (self, widget):
  10. print("Hello World")
  11. class OtherWindow (Gtk.Window):
  12. def __init__(self):
  13. Gtk.Window.__init__(self, title="Hello Baby!")
  14. self.box = Gtk.Box(spacing=6)
  15. self.add(self.box)
  16. self.button1 = Gtk.Button(label="hello there!")
  17. self.button1.connect("clicked", self.on_button1_clicked)
  18. self.box.pack_start(self.button1, True, True, 0)
  19. self.button2 = Gtk.Button(label="Goodbye")
  20. self.button2.connect("clicked", self.on_button2_clicked)
  21. self.box.pack_start(self.button2, True, True, 0)
  22. def on_button1_clicked(self, widget):
  23. print("Hello")
  24. def on_button2_clicked(self, widget):
  25. print("Goodbye")
  26. win = OtherWindow()
  27. win.connect("delete-event", Gtk.main_quit)
  28. win.show_all()
  29. Gtk.main()
  30. win = MyWindow()
  31. win.connect("delete-event", Gtk.main_quit)
  32. win.show_all()
  33. Gtk.main()