python - 网格中的 Gtk 滚动窗口大小

标签 python gtk

在 python 中试验 Gtk+3。

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

enter image description here

相关代码为:

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.

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

干杯, 菲尔

最佳答案

您需要做的是将GtkScrolledWindowhexpandvexpand 属性设置为True。您可以像这样在创建对象时执行此操作:

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

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

关于python - 网格中的 Gtk 滚动窗口大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14250927/

相关文章:

Python 多处理抛出 Killed : 9

python - 如何使用 LSB 替换将一张图像隐藏到另一张图像中?

animation - 使用 GTK+ 制作流畅的动画

c - 关于GThread和文件复制的问题

c - Gtk3 和 cairo 动画 twitch

python - 卷积神经网络?

python - 在 Python 3 中使用套接字传输文件

python - 在 python 中,1, 2 == 1, 2 是什么意思?

python : How can two GTK widgets interact with each other?

gtk - 实现一个可以滚动和响应缩放图像的图像查看器