4

在 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.

那么如何控制滚动区域的大小呢?

干杯,菲尔

4

1 回答 1

6

您需要做的是设置 to的hexpandvexpand属性。您可以像这样在对象创建上执行此操作:GtkScrolledWindowTrue

scroll = Gtk.ScrolledWindow(hexpand=True, vexpand=True)

如果您愿意,我建议您使用Glade来处理您的程序界面,因为您可以轻松访问所有小部件属性,因此解决此类问题会变得更加简单。

于 2013-01-10T06:53:48.970 回答