gtk treeview:将图像按钮放置在行上 [英] gtk treeview: place image buttons on rows

查看:475
本文介绍了gtk treeview:将图像按钮放置在行上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我的树状视图中的每一行,我需要4个图像按钮相邻。他们会像单选按钮一样,一次只能激活一个按钮。每个按钮都有一个开和关的图像。



我该怎么做?我想出了如何在那里放置图像,以及如何放置切换按钮,但这似乎需要更多的努力,因为没有预先构建的cellrenderer可以做我想做的事。

基本上解决我的问题的方法是找出如何在 gtk.treeview 中点击图片。任何想法?

解决方案

看看这个' http://www.daa.com.au/pipermail/pygtk/2010-March/018355.html '。它显示了如何使一个gtk.CellRendererPixbuf可激活,并能够连接到一个点击事件信号。

  cell = CellRendererPixbufXt( )
cell.connect('clicked',func)

更新



正如这个答案指出的那样,或者给出的参考文献不能像宣传的那样工作。它缺少do_activate方法,它需要发出点击信号。一旦完成了,cell.connect就可以工作。



很抱歉,如果这个答案误导了任何人。


For each row in my treeview, I want 4 image buttons next to each other. They will act like radio buttons, with only one being activateable at a time. Each button has an 'on' and 'off' image.

How do I do this? I figured out how to put images there, and how to put togglebuttons, but this seems to require some more effort as there is no pre-built cellrenderer that does what I want.

Basically what'd solve my problem is figuring out how to make an image in a gtk.treeview clickable. any ideas?

解决方案

Have a look at this 'http://www.daa.com.au/pipermail/pygtk/2010-March/018355.html'. It shows you how to make a gtk.CellRendererPixbuf activatable, and able to connect to a click event signal.

cell = CellRendererPixbufXt()
cell.connect('clicked', func)

Update

As pointed out this answer, or the reference given doesn't work as advertised. It's missing the do_activate method, which needs to emit the clicked signal. Once it's done that, then the cell.connect will work.

Sorry if this answer mislead anyone.

这篇关于gtk treeview:将图像按钮放置在行上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆