import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk window = Gtk.Window() button_box = Gtk.ButtonBox.new(Gtk.Orientation.VERTICAL) for i in range(3): button = Gtk.Button(label="Button {}".format(i)) button_box.pack_start(button, True, True, 0) window.add(button_box) window.show_all() Gtk.main()
import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk window = Gtk.Window() button_box = Gtk.ButtonBox.new(Gtk.Orientation.HORIZONTAL) for i in range(3): button = Gtk.Button(label="Button {}".format(i)) button_box.pack_start(button, True, True, 0) window.add(button_box) window.show_all() Gtk.main()Description: The examples demonstrate how to create a vertical and horizontal button box and add buttons to them using the `pack_start()` method. The `True` parameters specify that the buttons should expand and fill the available space, and the `0` parameter determines the amount of padding between the buttons. The package library used in this code is `Gtk` from the `gi.repository` module.