在 HPaned 问题中调整 gtk TreeView 的大小
我在 hpaned 的左侧有一个树视图,但是当我尝试将栏移动到左侧以使树视图小于其自动大小而不是调整树视图大小时,它会将整个程序窗口向右展开。关于如何解决这个问题有什么想法吗?
源的相关部分如下:
对于 hpaned。
self.vpan = gtk.VPaned()
self.hpan = gtk.HPaned()
self.vpan.show()
self.hpan.show()
self.vBox1.pack_end(self.hpan, True, True, 0)
self.hpan.pack2(self.vpan,True, True)
对于树视图。
self.ftree = gtk.TreeStore(str,str,str)
self.treefill(None, os.path.abspath(os.path.dirname(__file__)))
self.tree = gtk.TreeView(self.ftree)
self.tvcolumn = gtk.TreeViewColumn('Project')
self.tree.append_column(self.tvcolumn)
self.cellpb = gtk.CellRendererPixbuf()
self.celltxt = gtk.CellRendererText()
self.tvcolumn.pack_start(self.cellpb,False)
self.tvcolumn.pack_start(self.celltxt,True)
self.tvcolumn.set_attributes(self.cellpb, stock_id=0)
self.tvcolumn.set_attributes(self.celltxt, text=1)
self.tvcolumn.set_resizable(True)
self.hpan.pack1(self.tree,True,True)
self.tree.show()
I have a treeview in the left side of an hpaned but when I try to move the bar to the left to make the treeview smaller than its automatic size instead of resizing the treeview it expands the entire program window to the right. Any ideas on how to fix this?
The relevant portions of the source are the following:
For the hpaned.
self.vpan = gtk.VPaned()
self.hpan = gtk.HPaned()
self.vpan.show()
self.hpan.show()
self.vBox1.pack_end(self.hpan, True, True, 0)
self.hpan.pack2(self.vpan,True, True)
And for the tree View.
self.ftree = gtk.TreeStore(str,str,str)
self.treefill(None, os.path.abspath(os.path.dirname(__file__)))
self.tree = gtk.TreeView(self.ftree)
self.tvcolumn = gtk.TreeViewColumn('Project')
self.tree.append_column(self.tvcolumn)
self.cellpb = gtk.CellRendererPixbuf()
self.celltxt = gtk.CellRendererText()
self.tvcolumn.pack_start(self.cellpb,False)
self.tvcolumn.pack_start(self.celltxt,True)
self.tvcolumn.set_attributes(self.cellpb, stock_id=0)
self.tvcolumn.set_attributes(self.celltxt, text=1)
self.tvcolumn.set_resizable(True)
self.hpan.pack1(self.tree,True,True)
self.tree.show()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我正要回答这个问题,然后我发现我的答案是用户答案的重复。但是,由于他还没有发布他的决议作为答案,所以我无论如何都会发布。 (如果他没有弄清楚的话,我会发布以下内容。)
“扩展”和“填充”似乎会导致此框中的各个对象之间的空间争夺(因为我假设您的所有对象我以前也有这个习惯,但是没问题。)在PyGTK文档中,“Expand”被定义为
并将“填充”为:
所以,从本质上讲,盒子给所有东西都提供了相同的空间……你给一个东西更多的空间,它给另一个东西更多的空间,所有的物体都接受了它并变得更大。然后窗口必须扩展以进行补偿。
要解决此问题,请将这些选项中的一个或两个设置为“False”。将“Expand”设置为“False”也会关闭“Fill”,但只有将“Fill”设置为“False”才会导致框为“Fill-False”对象提供额外的空间作为填充。
I was going to answer this question, and then I realized that my answer was a repeat of the user's answer. But, as he hasn't posted his resolution as an answer, I will anyway. (Below is what I would have posted if he hadn't figured it out.)
Expand and Fill seem to be causing a bit of a fight for space between the various objects in this box (as I'm assuming that all of your objects do this. I used to have the habit, too, but no problem.) In the PyGTK documentation, "Expand" is defined as
and "Fill" as:
So, essentially, the box is giving everything the same space...you give more to one, it gives it to the other, and the objects all take it and get bigger. The window then has to expand to compensate.
To fix this, set one or both of those options to "False". Setting "Expand" to "False" will also shut off "Fill", but only setting "Fill" to "False" will cause the box to give the extra space to "Fill-False" objects as padding instead.