简体   繁体   中英

Python3, Gtk3 - GtkGrid expanding

A GtkWindow containing a GtkGrid containing some GtkLabel s won't expand when the window is grown. I want the grid to expand horizontally.

grid.set_hexpand(True) #No result
grid.expand = True     #No result

The GtkLabel in the rightmost column is set to align right so I can accurately see if it's being expanded or not:

label.set_halign(Gtk.Align.END)

Am I misunderstanding how a grid works? (A GtkTable had a set amount of columns, perhaps the GtkGrid doesn't and relies on it's sub elements being set to expand?)

If you want a GtkGrid to expand horizontally, you need to set the hexpand and hexpand-set properties of one the widgets contained in the grid.

Just use

label.set_hexpand(True)

The gtk_widget_set_hexpand method automatically sets both properties.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM