简体   繁体   English

Python GTK3 Treeview按钮

[英]Python GTK3 Treeview buttons

With GTK3 some Treeviews (I presume) have a few buttons at the bottom that appear to be part of it. 使用GTK3,一些Treeviews(我认为)在底部有一些按钮,似乎是它的一部分。 The System Settings in Ubuntu uses this, as well as the File Selector dialog for GTK3 apps Ubuntu中的系统设置使用它,以及GTK3应用程序的文件选择器对话框

示例树视图

Is this a part of GTK3 or just a specially made container? 这是GTK3的一部分还是仅仅是一个特制的容器?

In case anyone else comes here, the buttons are ToolButtons in a Toolbar with the "inline-toolbar" class 如果有其他人来到这里,按钮是ToolButtons在工具栏中的“内联工具栏”类

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)

I'm not sure if all the button specific properties are necessary 我不确定是否所有按钮特定属性都是必需的

I packed the treeview above the toolbar an a ScrolledWindow and gave it these properties 我将工具栏上方的树视图和ScrolledWindow打包并为其提供了这些属性

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

Then finally I packed the ScrolledWindow above the Toolbar in a VBox 最后我在一个VBox中将ScrolledWindow打包在工具栏上方

The add/remove/up/down buttons are separate controls from TreeView. 添加/删除/向上/向下按钮是TreeView的独立控件。 You'll have to add them to your UI and implement the behavior yourself. 您必须将它们添加到UI并自己实现该行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM