Python GTK3 Treeview 按钮

7

使用GTK3,一些树形视图(我猜)在底部有几个按钮,看起来好像是它的一部分。Ubuntu的系统设置和GTK3应用程序的文件选择对话框都使用了这个功能。

示例树形视图

这是GTK3的一部分还是一个特殊制作的容器?


这个问题已经被问过几次了,这里是另一个链接:http://stackoverflow.com/questions/8617788/how-to-change-the-style-for-buttons-in-gtk - ptomato
2个回答

7

如果有其他人来到这里,按钮是带有“inline-toolbar”类的工具栏中的ToolButton。

self.listTools=Gtk.Toolbar()
self.listTools.set_property("icon_size",1)
context=self.listTools.get_style_context()
context.add_class("inline-toolbar")

self.addButton=Gtk.ToolButton()
self.addButton.set_property("visible",True)
self.addButton.set_property("can_focus",False)
self.addButton.set_property("use_action_appearance",False)
self.addButton.set_property("use_underline",False)
self.addButton.set_property("icon_name","list-add-symbolic")
self.listTools.add(self.addButton)

我不确定是否所有的按钮相关属性都是必需的。

我将树形视图放在工具栏上方的滚动窗口中,并为其设置了以下属性:

scrolled_window = Gtk.ScrolledWindow()
scrolled_window.add_with_viewport(self.objectsView)
scrolled_window.set_property("shadow_type","in")

然后,我最终在VBox中将ScrolledWindow放置在工具栏之上。

0

添加/删除/向上/向下按钮是与TreeView分开的控件。 您需要将它们添加到您的用户界面,并自己实现其行为。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接