6

A GtkWindow containing a GtkGrid containing some GtkLabels 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?)

4

1 回答 1

8

如果要GtkGrid水平扩展,则需要设置网格中包含hexpand的一个小部件的和hexpand-set属性。

只需使用

label.set_hexpand(True)

gtk_widget_set_hexand方法会自动设置这两个属性。

于 2013-09-30T10:01:13.363 回答