1<?xml version='1.0' encoding='UTF-8'?> 2<page xmlns="http://projectmallard.org/1.0/" 3 xmlns:its="http://www.w3.org/2005/11/its" 4 xmlns:xi="http://www.w3.org/2001/XInclude" 5 type="guide" style="task" 6 id="treeview_cellrenderertoggle.py"> 7 <info> 8 <title type="text">TreeView with TreeStore (Python)</title> 9 <link type="guide" xref="beginner.py#treeview"/> 10 <link type="next" xref="widget_drawing.py"/> 11 <revision version="0.1" date="2012-06-30" status="draft"/> 12 13 <credit type="author copyright"> 14 <name>Marta Maria Casetti</name> 15 <email its:translate="no">mmcasetti@gmail.com</email> 16 <years>2012</years> 17 </credit> 18 19 <desc>A TreeView displaying a TreeStore (more complex example, with CellRendererToggle)</desc> 20 </info> 21 22 <title>More Complex TreeView with TreeStore</title> 23 <media type="image" mime="image/png" src="media/treeview_cellrenderertoggle.png"/> 24 <p>This TreeView displays a TreeStore with two columns, one of which is rendered as a toggle.</p> 25 26 <links type="section" /> 27 28 <section id="code"> 29 <title>Code used to generate this example</title> 30 31 <code mime="text/x-python" style="numbered"><xi:include href="samples/treeview_cellrenderertoggle.py" parse="text"><xi:fallback/></xi:include></code> 32 </section> 33 34 <section id="methods"> 35 <title>Useful methods for a TreeView widget</title> 36 <p>The TreeView widget is designed around a <em>Model/View/Controller</em> design: the <em>Model</em> stores the data; the <em>View</em> gets change notifications and displays the content of the model; the <em>Controller</em>, 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" />.</p> 37 <p>In line 48 the <code>"toggled"</code> signal is connected to the callback function <code>on_toggled()</code> using <code><var>widget</var>.connect(<var>signal</var>, <var>callback function</var>)</code>. See <link xref="signals-callbacks.py"/> for a more detailed explanation.</p> 38 </section> 39 40 <section id="references"> 41 <title>API References</title> 42 <p>In this sample we used the following:</p> 43 <list> 44 <item><p><link href="http://developer.gnome.org/gtk3/unstable/GtkTreeView.html">GtkTreeView</link></p></item> 45 <item><p><link href="http://developer.gnome.org/gtk3/unstable/GtkTreeModel.html">GtkTreeModel</link></p></item> 46 <item><p><link href="http://developer.gnome.org/gtk3/unstable/GtkTreeStore.html">GtkTreeStore</link></p></item> 47 <item><p><link href="http://developer.gnome.org/gtk3/unstable/GtkCellRendererText.html">GtkCellRendererText</link></p></item> 48 <item><p><link href="http://developer.gnome.org/gtk3/unstable/GtkCellRendererToggle.html">GtkCellRendererToggle</link></p></item> 49 <item><p><link href="http://developer.gnome.org/gtk3/unstable/GtkTreeViewColumn.html">GtkTreeViewColumn</link></p></item> 50 </list> 51 </section> 52</page> 53