如何控制 gtk.IconView 中的选择?
我想更改 gtk.IconView 选择框的不透明度或颜色(我实际上想让选择更加明显)。
我注意到 gtk.IconView 小部件具有样式属性 selection-box-alpha
& selection-box-color
但只能用于阅读。
gtk.TreeSelection
类的 set_select_function()
方法对于执行我想要的操作很有用,但它用于 gtk.TreeView
和我还没有找到 gtk.IconView 的等效项
那么,我该如何控制选择并在用户选择或取消选择内容时执行操作?
编辑 : 事实上,更改 selection-box-alpha
和 selection-box-color
样式属性的值并不是解决方案。 我真的不想改变选择框的不透明度,而是改变 pixbuf 的“不透明度”(通过与颜色合成)。 因此,我需要一个用于 gtk.IconView
小部件的 set_select_function
的等效方法。
I want to change the opacity or color of a gtk.IconView
select box (I want actually to make the selection more visible).
I noticed that the gtk.IconView
widget had style properties selection-box-alpha
& selection-box-color
but only accessible for reading.
The set_select_function()
method of the gtk.TreeSelection
class would have been useful to do what I want but it's used for a gtk.TreeView
and I haven't found an equivalent for gtk.IconView
So, how can I do to have control over the selection and perform an action when the user select or unselect stuff ?
Edit :
In fact, change the values of selection-box-alpha
and selection-box-color
style properties wouldn't be a solution.
I don't really want to change the selection box opacity but the "opacity" of the pixbuf (by compositing with a color).
So, I need an equivalent method of set_select_function
for a gtk.IconView
widget.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过实现根据选择状态绘制像素图的自定义
gtk.CellRenderer
并替换gtk.IconView
的默认单元格来设置像素图不透明度用你自己的渲染器。You might be able to set the pixmap opacity by implementing a custom
gtk.CellRenderer
that draws the pixmap according to the selection state, and replacing thegtk.IconView
's default cell renderer with your own.事实上,我们需要用具有
follow-state
属性的gtk.CellRendererPixbuf
替换gtk.IconView
的默认单元格渲染器。默认单元格渲染器,使用
gtk.IconView
继承的gtk.CellLayout
类。In fact, we need to replace the
gtk.IconView
's default cell renderer bygtk.CellRendererPixbuf
which havefollow-state
propertyWe replace the default cell renderer by using the
gtk.CellLayout
class whichgtk.IconView
inherits.