1from gi.repository import Gtk 2import sys 3 4 5class MyWindow(Gtk.ApplicationWindow): 6 7 def __init__(self, app): 8 Gtk.Window.__init__(self, title="Separator Example", application=app) 9 10 # three labels 11 label1 = Gtk.Label() 12 label1.set_text("Below, a horizontal separator.") 13 14 label2 = Gtk.Label() 15 label2.set_text("On the right, a vertical separator.") 16 17 label3 = Gtk.Label() 18 label3.set_text("On the left, a vertical separator.") 19 20 # a horizontal separator 21 hseparator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL) 22 # a vertical separator 23 vseparator = Gtk.Separator(orientation=Gtk.Orientation.VERTICAL) 24 25 # a grid to attach labels and separators 26 grid = Gtk.Grid() 27 grid.attach(label1, 0, 0, 3, 1) 28 grid.attach(hseparator, 0, 1, 3, 1) 29 grid.attach(label2, 0, 2, 1, 1) 30 grid.attach(vseparator, 1, 2, 1, 1) 31 grid.attach(label3, 2, 2, 1, 1) 32 grid.set_column_homogeneous(True) 33 # add the grid to the window 34 self.add(grid) 35 36 37class MyApplication(Gtk.Application): 38 39 def __init__(self): 40 Gtk.Application.__init__(self) 41 42 def do_activate(self): 43 win = MyWindow(self) 44 win.show_all() 45 46app = MyApplication() 47exit_status = app.run(sys.argv) 48sys.exit(exit_status) 49