English 中文(简体)
将gtk.TreeView列添加到大小组
原标题:Add gtk.TreeView columns to a size group

我想将两个树视图堆叠在一起,并使列对齐。我认为这样做的方法是以某种方式使用gtk.SizeGroup。但是,gtk.TreeViewColumn不是一个小部件。。。我该怎么做?

问题回答

我有两个建议:

  1. Look at how gtk.SizeGroup is implemented and see if you can write your own TreeViewColumnSizeGroup.
  2. Connect to notify::width of each column and in the callback set the width of the corresponding column in the other treeview.

更新:这是最后一个成功的代码。在循环中,我同时构建两个视图列,因此这一行就足够了:

col1.connect("notify::width", lambda col1,_,col2:col2.set_fixed_width(
    col1.get_width()), col2)

我认为没有“列小部件”的原因是主要区域只是一个gtk.gdk.Drawable,每个单元渲染器都在这里绘制自己的东西。然而,每一列都有小部件的标题,所以我们可以使用它们来做我们想要的事情。

选择一个视图作为主视图,并将另一个设置为具有gtk.TREE_view_COLUMN_FIXED大小。使用.forall()浏览主视图的内部子窗口小部件。这些将是代表列标题的gtk.按钮。连接到他们的大小分配事件。在该事件处理程序上,获取请求的宽度,以及从属视图上相应列的.set_fixed_width

    self._svcols = []
    def sizealloc(wid, alloc):
        ci = self._svcols.index(wid)
        cl = self.slaveView.get_column(ci)
        cl.set_fixed_width(alloc.width)

    def resizes(child):
        child.connect( size-allocate , sizealloc)
        self._svcols.append(child)

    self.mainView.forall(resizes)

即使没有显示列标题,这也能起作用。





相关问题
How to start to create an application GUI using C#?

HI! I am new to C# and plan to use it for my application GUI. I am trying to make my GUI similar to SPSS:http://www.spss.com/images/08/statistics_screens/ez_rfm-big.jpg Is this easy in C#? Is there ...

Automatic height of edit box

My shoes application has three items stacked on top of each other (with a stack, of course), in order: A banner An edit box Two buttons in a flow What I want to do is have the banner stay at it s ...

Search by using the keyboard in a list/grid - algorithm

I need to implement a custom search in a grid and I would like to find some user interface guidelines that explain the standard way to implement it. I mean this kind of search that is initiated by ...

UI And TcpClient Issue in vb.net

I m having some problems with a small ircbot i m writing. Basically I connect to the server using a tcpclient in a seperate class, which also runs on its own thread. I want to display the server text ...

UI Convention: Shortcut key for application exit? [closed]

Is there a convention for the shortcut keys for application exit? Some applications uses Alt+X some others use Ctrl+ X and Ctrl+Q. Applications like FF and IE doesnot assign a shortcut at all. So is ...

热门标签