Reputation:
I'm fairly new to GTK+3 (I use PyGObject) and I need to create a sidebar that has a structure like this:
Header 1
Subheader 1
Subheader 2
Header 2
Subheader 3
Subheader 4
What examples can I learn from? Could you show me a minimal working example of how to use Gtk.Treeview
and Gtk.TreeModel
(not using Gtk.Builder()
)?
Besides using a xml file and Gtk.Builder()
to describe the layout seems superior to creating the structure in the python file, but there seems to be much less documentation for doing so.
My current UI description:
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<object class="GtkWindow" id="main-window">
<property name="title">ApplicationName</property>
<signal name="delete-event" handler="onDeleteWindow"/>
<child>
<object class="GtkBox" id="container">
<property name="orientation">horizontal</property>
<child>
<object class="GtkTreeView" id="sidebar">
</object>
</child>
<child>
<object class="GtkBox" id="right-container">
<property name="orientation">vertical</property>
<child>
<object class="GtkButtonBox" id="top-buttonbox">
<child>
<object class="GtkButton" id="add-button">
<property name="label">Add</property>
</object>
</child>
<child>
<object class="GtkButton" id="delete-button">
<property name="label">Delete</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</interface>
Upvotes: 1
Views: 2450
Reputation: 2181
You should have a look at the GtkTreeView
and the associated tree-like data model GtkTreeStore
. The Python GTK+ 3.0 Tutorial is a good introduction.
Upvotes: 4