Search code examples
pygtk

PyGtk3, How to prevent horizontal expand in VBox?


i can prevent vertical expand in VBox with pack_start(button, expand = False, fill = False, padding = 0) command but widgets in VBox always expanding horizontally. i want make widget in center on horizontal plane. is there a method for make widget in center on horizontal plane ?


Solution

  • set_halign() method can do this

    button = Gtk.Button()
    button.set_halign(Gtk.Align.CENTER) # to center the widget
    

    or

    button = Gtk.Button(halign = Gtk.Align.CENTER)