import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk class AlignmentWindow(Gtk.Window): def __init__(self): Gtk.Window.__init__(self, title="Alignment Example") self.set_border_width(10) image = Gtk.Image.new_from_file("myimage.png") align = Gtk.Alignment() align.set(0.5, 0.5, 0, 0) align.add(image) self.add(align) win = AlignmentWindow() win.connect("destroy", Gtk.main_quit) win.show_all() Gtk.main()
import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk class AlignmentWindow(Gtk.Window): def __init__(self): Gtk.Window.__init__(self, title="Alignment Example") self.set_border_width(10) label = Gtk.Label("Hello, world!") align = Gtk.Alignment() align.set(0, 0.5, 0, 0) align.add(label) self.add(align) win = AlignmentWindow() win.connect("destroy", Gtk.main_quit) win.show_all() Gtk.main()This example uses a Gtk.Label widget as the child widget of a Gtk.Alignment container. The align.set(0, 0.5, 0, 0) call left-aligns the label within the container. Package Library: The package library used in this example is "gi.repository Gtk".