How to center a window with PyGObject How to center a window with PyGObject python python

How to center a window with PyGObject


pydoc tells you what you need to know:

>>> help(window.set_position)Help on method set_position in module gi.repository.Gtk:set_position(*args, **kwargs) method of gi.overrides.Gtk.Window instance    set_position(self, position:Gtk.WindowPosition)

Gtk.WindowPosition wraps the enum values, so try:

window.set_position(Gtk.WindowPosition.CENTER)

edit: seems that for newer versions the docstring isn't displayed by help(window.set_position) anymore, use help(window) (or print(window.get_position.__doc__)) instead.