[英]Python3, Gtk3 - GtkGrid expanding
A GtkWindow
containing a GtkGrid
containing some GtkLabel
s won't expand when the window is grown. 甲
GtkWindow
含有GtkGrid
含有一些GtkLabel
当生长在画面S不会扩大。 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: 最右边一列中的
GtkLabel
设置为右对齐,这样我就可以准确地看到它是否被扩展:
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?) (一个
GtkTable
有一定数量的列,也许GtkGrid
没有并依赖于它的子元素被设置为扩展?)
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. 如果希望
GtkGrid
水平扩展,则需要设置网格中包含的小部件的hexpand
和hexpand-set
属性。
Just use 只是用
label.set_hexpand(True)
The gtk_widget_set_hexpand method automatically sets both properties. gtk_widget_set_hexpand方法自动设置这两个属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.