Blame platform-demos/C/treeview_advanced_liststore.py.page

Packit 1470ea
Packit 1470ea
Packit 1470ea
      xmlns:its="http://www.w3.org/2005/11/its"
Packit 1470ea
      xmlns:xi="http://www.w3.org/2001/XInclude"
Packit 1470ea
      type="guide" style="task"
Packit 1470ea
      id="treeview_advanced_liststore.py">
Packit 1470ea
  <info>
Packit 1470ea
    <title type="text">Simple Treeview with ListStore (Python)</title>
Packit 1470ea
    <link type="guide" xref="beginner.py#treeview"/>
Packit 1470ea
    <link type="next" xref="treeview_cellrenderertoggle.py"/>
Packit 1470ea
    <revision version="0.1" date="2012-06-30" status="draft"/>
Packit 1470ea
Packit 1470ea
    <credit type="author copyright">
Packit 1470ea
      <name>Marta Maria Casetti</name>
Packit 1470ea
      <email its:translate="no">mmcasetti@gmail.com</email>
Packit 1470ea
      <years>2012</years>
Packit 1470ea
    </credit>
Packit 1470ea
Packit 1470ea
    <desc>A TreeView displaying a ListStore (more complex example)</desc>
Packit 1470ea
  </info>
Packit 1470ea
Packit 1470ea
  <title>More Complex Treeview with ListStore</title>
Packit 1470ea
  <media type="image" mime="image/png" src="media/treeview_advanced_liststore.png"/>
Packit 1470ea
  

This TreeView displays a simple ListStore with the selection "changed" signal connected.

Packit 1470ea
Packit 1470ea
  <links type="section" />
Packit 1470ea
Packit 1470ea
  <section id="code">
Packit 1470ea
    <title>Code used to generate this example</title>
Packit 1470ea
Packit 1470ea
    <xi:include href="samples/treeview_advanced_liststore.py" parse="text"><xi:fallback/></xi:include>
Packit 1470ea
  </section>
Packit 1470ea
Packit 1470ea
  <section id="methods">
Packit 1470ea
    <title>Useful methods for a TreeView widget</title>
Packit 1470ea
    

The TreeView widget is designed around a Model/View/Controller design: the Model stores the data; the View gets change notifications and displays the content of the model; the Controller, finally, changes the state of the model and notifies the view of these changes. For more information and for a list of useful methods for TreeModel see <link xref="model-view-controller.py" />.

Packit 1470ea
    

In line 36 the "changed" signal is connected to the callback function on_changed() using widget.connect(signal, callback function). See <link xref="signals-callbacks.py"/> for a more detailed explanation.

Packit 1470ea
  </section>
Packit 1470ea
Packit 1470ea
  <section id="references">
Packit 1470ea
    <title>API References</title>
Packit 1470ea
    

In this sample we used the following:

Packit 1470ea
    <list>
Packit 1470ea
      <item>

<link href="http://developer.gnome.org/gtk3/unstable/GtkTreeView.html">GtkTreeView</link>

</item>
Packit 1470ea
      <item>

<link href="http://developer.gnome.org/gtk3/unstable/GtkTreeModel.html">GtkTreeModel</link>

</item>
Packit 1470ea
      <item>

<link href="http://developer.gnome.org/gtk3/unstable/GtkListStore.html">GtkListStore</link>

</item>
Packit 1470ea
      <item>

<link href="http://developer.gnome.org/gtk3/unstable/GtkCellRendererText.html">GtkCellRendererText</link>

</item>
Packit 1470ea
      <item>

<link href="http://developer.gnome.org/gtk3/unstable/GtkTreeViewColumn.html">GtkTreeViewColumn</link>

</item>
Packit 1470ea
      <item>

<link href="http://git.gnome.org/browse/pygobject/tree/gi/overrides/Gtk.py">pygobject - Python bindings for GObject Introspection</link>

</item>
Packit 1470ea
    </list>
Packit 1470ea
  </section>
Packit 1470ea
</page>