在python中试验Gtk+3。
尝试将滚动窗口容器内的"Gtk.TreeView“与输入框一起添加到网格窗口。问题是滚动区域很小,因此您几乎看不到任何滚动窗口/TreeView。以下是输出的图像:

相关代码为:
scroll = Gtk.ScrolledWindow() # Create scroll window
scroll.add(self.MatchTree) # Adds the TreeView to the scroll container
grid = Gtk.Grid() # Create grid container
self.add(Grid) # Add grid to window (self)
Grid.add(scroll) # Add scroll window to grid
Grid.attach_next_to(self.Entry, scroll, Gtk.PositionType.BOTTOM, 1, 1) # Attach entry to bottom of grid.那么如何控制滚动区域的大小呢?
干杯,菲尔
发布于 2013-01-10 14:53:49
您需要做的是将GtkScrolledWindow的hexpand和vexpand属性设置为True。您可以在创建对象时执行以下操作:
scroll = Gtk.ScrolledWindow(hexpand=True, vexpand=True)如果你准备好了,我建议你使用Glade来处理你的程序界面,这使得解决这类问题变得简单得多,因为你可以很容易地访问所有的小部件属性。
https://stackoverflow.com/questions/14250927
复制相似问题