grid.py 641 B

123456789101112131415161718192021222324252627
  1. #!/usr/bin/python
  2. from gi.repository import Gtk
  3. class GridWindow (Gtk.Window):
  4. def __init__(self):
  5. Gtk.Window.__init__(self, title="Grid Example")
  6. grid = Gtk.Grid()
  7. self.add (grid)
  8. button1 = Gtk.Button(label="Button 1")
  9. button2 = Gtk.Button(label="Button 2")
  10. button3 = Gtk.Button(label="Button 3")
  11. button4 = Gtk.Button(label="Button 4")
  12. grid.add(button1)
  13. grid.attach(button2, 1, 0, 1, 1)
  14. grid.attach(button3, 0, 1, 1, 1)
  15. grid.attach(button4, 1, 1, 1, 1)
  16. win = GridWindow()
  17. win.connect("delete-event", Gtk.main_quit)
  18. win.show_all()
  19. Gtk.main()