python - Homogeneous children in ButtonBox -
i added few children buttonbox, , wanted them not homogeneous. called buttonbox.set_homogeneous(false) , worked. when resize window bellow minimum size, , vertical scrollbar appears, see there lot of empty space bellow buttonbox. able fix individually specifying each children non homogeneous calling buttonbox.set_child_non_homogeneous(child, true), while leaving in previous call buttonbox.set_homogeneous(false).
my question then, why happen? set buttonbox's layout expand, space should taken.
i made little test code illustrate i'm talking about. can try , without commented line see both cases mentioned.
import sys gi.repository import gtk class application(gtk.application): def __init__(self): super().__init__(application_id='com.stackoverflow.xor') self.connect('activate', self.on_activate) self.connect('startup', self.on_startup) def on_startup(self, app): self.window = gtk.applicationwindow(application=app) self.window.set_default_size(200, 200) self.window.add(mainview(self)) def on_activate(self, app): self.window.show_all() class mainview(gtk.scrolledwindow): def __init__(self, app): super().__init__() button_list = gtk.buttonbox(orientation=gtk.orientation.vertical) button_list.set_layout(gtk.buttonboxstyle.expand) button_list.set_homogeneous(false) button_list.get_style_context().remove_class('linked') in range(4): button = gtk.button() label = gtk.label('\n'.join(['test test'] * (i + 1))) button.add(label) button_list.pack_start(button, false, false, 0) #button_list.set_child_non_homogeneous(button, true) self.add(button_list) if __name__ == '__main__': main_app = application() exit_status = main_app.run(sys.argv) sys.exit(exit_status)
your issue when adding buttons box set expand false.
button_list.pack_start(button, false, false, 0)
the buttonbox having expand layout not same children expanding themselves.
edit: discussed on #gtk+ children should have expand , fill set true layout.
Comments
Post a Comment