import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk win = Gtk.Window() hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) button1 = Gtk.Button(label="Button 1") button2 = Gtk.Button(label="Button 2") hbox.pack_start(button1, True, True, 0) hbox.pack_start(button2, True, True, 0) win.add(hbox) win.show_all() Gtk.main()
import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk win = Gtk.Window() vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) label = Gtk.Label("This is a label") entry = Gtk.Entry() vbox.pack_start(label, True, True, 0) vbox.pack_start(entry, True, True, 0) win.add(vbox) win.show_all() Gtk.main()This creates a vertical box container and adds a label and an entry field to it, then adds the box to a window so it can be displayed. These examples use the Gtk package library provided by the GObject Introspection library in Python.