在 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.
那么如何控制滚动区域的大小呢?
干杯, 菲尔
最佳答案
您需要做的是将GtkScrolledWindow
的hexpand
和vexpand
属性设置为True
。您可以像这样在创建对象时执行此操作:
scroll = Gtk.ScrolledWindow(hexpand=True, vexpand=True)
如果您愿意,我建议您使用 Glade为了处理您的程序界面,解决此类问题会变得更加简单,因为您可以轻松访问所有小部件属性。
关于python - 网格中的 Gtk 滚动窗口大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14250927/