[gnome-devel-docs] tutorials python: treeview widgets, samples and pages
- From: Tiffany Antopolski <antopolski src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-devel-docs] tutorials python: treeview widgets, samples and pages
- Date: Mon, 2 Jul 2012 02:34:37 +0000 (UTC)
commit a918d1532805efc70cfbb5c798bddff734284e03
Author: Marta Maria Casetti <mmcasetti gmail com>
Date: Sat Jun 30 22:38:28 2012 +0100
tutorials python: treeview widgets, samples and pages
.../C/media/treeview_advanced_liststore.png | Bin 0 -> 16193 bytes
.../C/media/treeview_cellrenderertoggle.png | Bin 0 -> 12737 bytes
platform-demos/C/media/treeview_treestore.png | Bin 0 -> 10568 bytes
platform-demos/C/model-view-controller.py.page | 167 ++++++++++++++++++++
.../C/samples/treeview_advanced_liststore.py | 129 +++++++++++++++
.../C/samples/treeview_cellrenderertoggle.py | 101 ++++++++++++
.../C/samples/treeview_simple_liststore.py | 22 ++--
platform-demos/C/samples/treeview_treestore.py | 59 +++++++
.../C/treeview_advanced_liststore.py.page | 52 ++++++
.../C/treeview_cellrenderertoggle.py.page | 48 ++++++
platform-demos/C/treeview_simple_liststore.py.page | 45 ++++--
platform-demos/C/treeview_treestore.py.page | 47 ++++++
platform-demos/Makefile.am | 10 ++
13 files changed, 654 insertions(+), 26 deletions(-)
---
diff --git a/platform-demos/C/media/treeview_advanced_liststore.png b/platform-demos/C/media/treeview_advanced_liststore.png
new file mode 100644
index 0000000..2150d13
Binary files /dev/null and b/platform-demos/C/media/treeview_advanced_liststore.png differ
diff --git a/platform-demos/C/media/treeview_cellrenderertoggle.png b/platform-demos/C/media/treeview_cellrenderertoggle.png
new file mode 100644
index 0000000..64a510a
Binary files /dev/null and b/platform-demos/C/media/treeview_cellrenderertoggle.png differ
diff --git a/platform-demos/C/media/treeview_treestore.png b/platform-demos/C/media/treeview_treestore.png
new file mode 100644
index 0000000..055b9d0
Binary files /dev/null and b/platform-demos/C/media/treeview_treestore.png differ
diff --git a/platform-demos/C/model-view-controller.py.page b/platform-demos/C/model-view-controller.py.page
new file mode 100644
index 0000000..8d4d3f0
--- /dev/null
+++ b/platform-demos/C/model-view-controller.py.page
@@ -0,0 +1,167 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<page xmlns="http://projectmallard.org/1.0/"
+ xmlns:e="http://projectmallard.org/experimental/"
+ type="guide" style="task"
+ id="model-view-controller.py">
+
+<info>
+ <link type="guide" xref="beginner.py#tutorials"/>
+ <revision version="0.1" date="2012-06-30" status="stub"/>
+
+ <desc>The Model/View/Controller design</desc>
+ <credit type="author copyright">
+ <name>Sebastian Pölsterl</name>
+ <email>sebp k-d-w org</email>
+ <years>2011</years>
+ </credit>
+ <credit type="author copyright editor">
+ <name>Marta Maria Casetti</name>
+ <email>mmcasetti gmail com</email>
+ <years>2012</years>
+ </credit>
+</info>
+
+<title>The Model/View/Controller design</title>
+
+<links type="section" />
+
+<section id="overview">
+<title>Overview</title>
+
+<p>Both the <link xref="treeview_simple_liststore.py">TreeView</link> and the <link xref="combobox.py">ComboBox</link> widgets are built on the <em>Model/View/Controller</em> design. The <em>Model</em> (an implementation of <code>Gtk.TreeModel</code>, usually <code>Gtk.TreeStore</code> or <code>Gtk.ListStore</code>) 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 (via some methods in the model's implementation - such as <code>append()</code>) and notifies the view of these changes (via signals like <code>"changed"</code>).</p>
+
+<p>The data in the Model can be retrieved or modified using the tree iter and column index, or <code>Gtk.TreeIter</code>, or <code>Gtk.TreePath</code>.</p>
+
+<p>The View makes use of <code>Gtk.CellRenderer</code>s of various types to draw the data; in the case of the TreeView, also <code>Gtk.TreeViewColumn</code> is used, to organize the vertical columns. Examples of Views are <code>Gtk.TreeView</code>, <code>Gtk.ComboBox</code>, and <code>Gtk.ComboBoxText</code>.</p>
+
+</section>
+
+<section id="model">
+<title>The Model</title>
+
+<p>The main difference between the two main implementations of <code>Gtk.TreeModel</code> is that <code>Gtk.ListStore</code> contains simple rows of data, and each row has no children, whereas <code>Gtk.TreeStore</code> contains rows of data, and each row may have child rows.</p>
+
+<p>As with Python's built-in list object you can use <code>len()</code> to get the number of rows and use slices to retrieve or set values. Otherwise, the method <code>append()</code> returns a <code>Gtk.TreeIter</code> instance, which points to the location of the newly inserted row. Retrieve a <code>Gtk.TreeIter</code> by calling <code>get_iter()</code>.</p>
+
+<p>As <code>Gtk.ListStore</code> contains only one level, i.e. nodes do not have any child nodes, a path is essentially the index of the row you want to access. In the case of <code>Gtk.TreeStore</code>, a path is a list of indexes or a string. The string form is a list of numbers separated by a colon. Each number refers to the offset at that level. Thus, the path <code>"0"</code> refers to the root node and the path <code>"2:4"</code> refers to the fifth child of the third node.</p>
+
+<p>Useful methods for a <code>Gtk.TreeModel</code>:</p>
+<list>
+ <item><p></p></item>
+ <item><p></p></item>
+ <item><p></p></item>
+ <item><p></p></item>
+ <item><p></p></item>
+ <item><p></p></item>
+</list>
+
+<p>Useful methods for a <code>Gtk.ListStore</code>:</p>
+<list>
+ <item><p></p></item>
+ <item><p></p></item>
+ <item><p></p></item>
+ <item><p></p></item>
+ <item><p></p></item>
+ <item><p></p></item>
+</list>
+
+<p>Useful methods for a <code>Gtk.TreeStore</code>:</p>
+<list>
+ <item><p></p></item>
+ <item><p></p></item>
+ <item><p></p></item>
+ <item><p></p></item>
+ <item><p></p></item>
+ <item><p></p></item>
+</list>
+
+</section>
+
+<section id="treeview">
+<title>The View: the TreeView case</title>
+
+<p>Useful methods for a <code>Gtk.TreeView</code>:</p>
+<list>
+ <item><p></p></item>
+ <item><p></p></item>
+ <item><p></p></item>
+ <item><p></p></item>
+ <item><p></p></item>
+ <item><p></p></item>
+</list>
+
+<p>Useful methods for a <code>Gtk.TreeViewColumn</code>:</p>
+<list>
+ <item><p></p></item>
+ <item><p></p></item>
+ <item><p></p></item>
+ <item><p></p></item>
+ <item><p></p></item>
+ <item><p></p></item>
+</list>
+
+</section>
+
+
+<section id="combobox">
+<title>The View: the ComboBox case</title>
+
+<p>Useful methods for a <code>Gtk.ComboBox</code>:</p>
+<list>
+ <item><p></p></item>
+ <item><p></p></item>
+ <item><p></p></item>
+ <item><p></p></item>
+ <item><p></p></item>
+ <item><p></p></item>
+</list>
+
+<p>Useful methods for a <code>Gtk.ComboBoxText</code>:</p>
+<list>
+ <item><p></p></item>
+ <item><p></p></item>
+ <item><p></p></item>
+ <item><p></p></item>
+ <item><p></p></item>
+ <item><p></p></item>
+</list>
+
+</section>
+
+<section id="cellrenderer">
+<title>The View: the Cellrenderers</title>
+
+<p>Implementations of <code>Gtk.CellRenderer</code> and useful methods:</p>
+<list>
+ <item><p><code>Gtk.CellRendererText</code> - renders text in a cell</p></item>
+ <item><p><code>Gtk.CellRendererToggle</code> - renders a toggle button in a cell. Useful methods:</p>
+ <list>
+ <item><p><code>set_active(setting)</code> - activates or deactivates a cell renderer</p></item>
+ <item><p><code>get_active()</code> - returns whether the cell renderer is active</p></item>
+ <item><p><code>set_radio(radio)</code> - if radio is <code>True</code>, the cell renderer renders a radio toggle (i.e. a toggle in a group of mutually-exclusive toggles); if <code>False</code>, it renders a check toggle (a standalone boolean option)</p></item>
+ <item><p><code>get_radio()</code> - returns whether we are rendering radio toggles rather than checkboxes.</p></item>
+ </list>
+ </item>
+ <item><p><code>Gtk.CellRendererPixbuf</code> - renders an image in a cell</p></item>
+ <item><p><code>Gtk.CellRendererCombo</code> - renders text in a cell; but while <code>Gtk.CellRendererText</code> offers a simple entry to edit the text, <code>Gtk.CellRendererCombo</code> offers a <code>Gtk.ComboBox</code> widget to edit the text. It can be used with and without an associated Gtk.Entry widget, depending on the value of the âhas-entryâ property.</p></item>
+ <item><p><code>Gtk.CellRendererProgress</code> - renders a numeric value as a progress bar in a cell; it can display a text on top of the progress bar</p></item>
+ <item><p><code>Gtk.CellRendererSpinner</code> - renders a spinning animation in a cell</p></item>
+ <item><p><code>Gtk.CellRendererSpin</code> - renders a spin button in a cell</p></item>
+ <item><p><code>Gtk.CellRendererAccel</code> - renders a keyboard accelerator in a cell</p></item>
+</list>
+
+</section>
+
+<section id="references">
+<title>References</title>
+
+<list>
+ <item><p><link href="http://python-gtk-3-tutorial.readthedocs.org/en/latest/treeview.html">The Python Gtk+ 3 Tutorial - Tree and List Widgets</link></p></item>
+ <item><p><link href="http://python-gtk-3-tutorial.readthedocs.org/en/latest/cellrenderers.html">The Python Gtk+ 3 Tutorial - CellRenderers</link></p></item>
+ <item><p><link href="http://python-gtk-3-tutorial.readthedocs.org/en/latest/combobox.html">The Python Gtk+ 3 Tutorial - ComboBox</link></p></item>
+ <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkCellRenderer.html">GtkCellRenderer</link></p></item>
+</list>
+
+</section>
+
+</page>
diff --git a/platform-demos/C/samples/treeview_advanced_liststore.py b/platform-demos/C/samples/treeview_advanced_liststore.py
new file mode 100644
index 0000000..30f0f8b
--- /dev/null
+++ b/platform-demos/C/samples/treeview_advanced_liststore.py
@@ -0,0 +1,129 @@
+from gi.repository import Gtk
+from gi.repository import Pango
+import sys
+
+list_of_dvd = [["The Usual Suspects"],
+ ["Gilda"],
+ ["The Godfather"],
+ ["Pulp Fiction"],
+ ["Once Upon a Time in the West"],
+ ["Rear Window"]]
+
+class MyWindow(Gtk.ApplicationWindow):
+ def __init__(self, app):
+ Gtk.Window.__init__(self, title="My DVDs", application=app)
+ self.set_default_size(250, 100)
+ self.set_border_width(10)
+
+ # the data are stored in the model
+ # create a liststore with one column
+ self.listmodel = Gtk.ListStore(str)
+ for i in range(len(list_of_dvd)):
+ self.listmodel.append(list_of_dvd[i])
+
+ # a treeview to see the data stored in the model
+ view = Gtk.TreeView(model=self.listmodel)
+
+ # cellrenderer for the first column
+ cell = Gtk.CellRendererText()
+ # the first column is created
+ col = Gtk.TreeViewColumn("Title", cell, text=0)
+ # and it is appended to the treeview
+ view.append_column(col)
+
+ # when a row of the treeview is selected, it emits a signal
+ self.selection = view.get_selection()
+ self.selection.connect("changed", self.on_changed)
+
+ # the label we use to show the selection
+ self.label = Gtk.Label()
+ self.label.set_text("")
+
+ # a button to add new titles, connected to a callback function
+ self.button_add = Gtk.Button(label="Add")
+ self.button_add.connect("clicked", self.add_cb)
+
+ # an entry to enter titles
+ self.entry = Gtk.Entry()
+
+ # a button to remove titles, connected to a callback function
+ self.button_remove = Gtk.Button(label="Remove")
+ self.button_remove.connect("clicked", self.remove_cb)
+
+ # a button to remove all titles, connected to a callback function
+ self.button_remove_all = Gtk.Button(label="Remove All")
+ self.button_remove_all.connect("clicked", self.remove_all_cb)
+
+ # a grid to attach the widgets
+ grid = Gtk.Grid()
+ grid.attach(view, 0, 0, 4, 1)
+ grid.attach(self.label, 0, 1, 4, 1)
+ grid.attach(self.button_add, 0, 2, 1, 1)
+ grid.attach_next_to(self.entry, self.button_add, Gtk.PositionType.RIGHT, 1, 1)
+ grid.attach_next_to(self.button_remove, self.entry, Gtk.PositionType.RIGHT, 1, 1)
+ grid.attach_next_to(self.button_remove_all, self.button_remove, Gtk.PositionType.RIGHT, 1, 1)
+
+ # add the grid to the window
+ self.add(grid)
+
+ def on_changed(self, selection):
+ # get the model and the iterator that points at the data in the model
+ (model, iter) = selection.get_selected()
+ # set the label to a new value depending on the selection, if there is one
+ if iter is not None:
+ self.label.set_text("\n %s" %(model[iter][0]))
+ else:
+ self.label.set_text("")
+ return True
+
+ # callback function for the "Add" button
+ def add_cb(self, button):
+ # append to the model the title that is in the entry
+ title = self.entry.get_text()
+ self.listmodel.append([title])
+ # and print a message in the terminal
+ print "%s has been added" %(title)
+
+ def remove_cb(self, button):
+ # if there is still an entry in the model
+ if len(self.listmodel) != 0:
+ # get the selection
+ (model, iter) = self.selection.get_selected()
+ # if there is a selection, print a message in the terminal
+ # and remove it from the model
+ if iter is not None:
+ print "%s has been removed" %(model[iter][0])
+ self.listmodel.remove(iter)
+ # otherwise, ask the user to select something to remove
+ else:
+ print "Select a title to remove"
+ # else, if there are no entries in the model, print "Empty list"
+ # in the terminal
+ else:
+ print "Empty list"
+
+ def remove_all_cb(self, button):
+ # if there is still an entry in the model
+ if len(self.listmodel) != 0:
+ # remove all the entries in the model
+ for i in range(len(self.listmodel)):
+ iter = self.listmodel.get_iter(0)
+ self.listmodel.remove(iter)
+ # print a message in the terminal alerting that the model is empty
+ print "Empty list"
+
+
+class MyApplication(Gtk.Application):
+ def __init__(self):
+ Gtk.Application.__init__(self)
+
+ def do_activate(self):
+ win = MyWindow(self)
+ win.show_all()
+
+ def do_startup(self):
+ Gtk.Application.do_startup(self)
+
+app = MyApplication()
+exit_status = app.run(sys.argv)
+sys.exit(exit_status)
diff --git a/platform-demos/C/samples/treeview_cellrenderertoggle.py b/platform-demos/C/samples/treeview_cellrenderertoggle.py
new file mode 100644
index 0000000..d8e3868
--- /dev/null
+++ b/platform-demos/C/samples/treeview_cellrenderertoggle.py
@@ -0,0 +1,101 @@
+from gi.repository import Gtk
+from gi.repository import Pango
+import sys
+
+books = [["Tolstoy, Leo", ["War and Peace", True], ["Anna Karenina", False]],
+ ["Shakespeare, William", ["Hamlet", False], ["Macbeth", True], ["Othello", False]],
+ ["Tolkien, J.R.R.", ["The Lord of the Rings", False]]]
+
+class MyWindow(Gtk.ApplicationWindow):
+ def __init__(self, app):
+ Gtk.Window.__init__(self, title="Library", application=app)
+ self.set_default_size(250, 100)
+ self.set_border_width(10)
+
+ # the data are stored in the model
+ # create a treestore with two columns
+ self.store = Gtk.TreeStore(str, bool)
+ # fill in the model
+ for i in range(len(books)):
+ # the iter piter is returned when appending the author in the first column
+ # and False in the second
+ piter = self.store.append(None, [books[i][0], False])
+ # append the books and the associated boolean value as children of the author
+ j = 1
+ while j < len(books[i]):
+ self.store.append(piter, books[i][j])
+ j += 1
+
+ # the treeview shows the model
+ # create a treeview on the model self.store
+ view = Gtk.TreeView()
+ view.set_model(self.store)
+
+ # the cellrenderer for the first column - text
+ renderer_books = Gtk.CellRendererText()
+ # the first column is created
+ column_books = Gtk.TreeViewColumn("Books", renderer_books, text=0)
+ # and it is appended to the treeview
+ view.append_column(column_books)
+
+ # the cellrenderer for the second column - boolean rendered as a toggle
+ renderer_in_out = Gtk.CellRendererToggle()
+ # the second column is created
+ column_in_out = Gtk.TreeViewColumn("Out?", renderer_in_out, active=1)
+ # and it is appended to the treeview
+ view.append_column(column_in_out)
+ # connect the cellrenderertoggle with a callback function
+ renderer_in_out.connect("toggled", self.on_toggled)
+
+ # add the treeview to the window
+ self.add(view)
+
+ # callback function for the signal emitted by the cellrenderertoggle
+ def on_toggled(self, widget, path):
+ # the boolean value of the selected row
+ current_value = self.store[path][1]
+ # change the boolean value of the selected row in the model
+ self.store[path][1] = not current_value
+ # new current value!
+ current_value = not current_value
+ # if length of the path is 1 (that is, if we are selecting an author)
+ if len(path) == 1:
+ # get the iter associated with the path
+ piter = self.store.get_iter(path)
+ # get the iter associated with its first child
+ citer = self.store.iter_children(piter)
+ # while there are children, change the state of their boolean value
+ # to the value of the author
+ while citer is not None:
+ self.store[citer][1] = current_value
+ citer = self.store.iter_next(citer)
+ # if the length of the path is not 1 (that is, if we are selecting a book)
+ elif len(path) != 1:
+ # get the first child of the parent of the book (the first book of the author)
+ citer = self.store.get_iter(path)
+ piter = self.store.iter_parent(citer)
+ citer = self.store.iter_children(piter)
+ # check if all the children are selected
+ all_selected = True
+ while citer is not None:
+ if self.store[citer][1] == False:
+ all_selected = False
+ break
+ citer = self.store.iter_next(citer)
+ # if they do, the author as well is selected; otherwise it is not
+ self.store[piter][1] = all_selected
+
+class MyApplication(Gtk.Application):
+ def __init__(self):
+ Gtk.Application.__init__(self)
+
+ def do_activate(self):
+ win = MyWindow(self)
+ win.show_all()
+
+ def do_startup(self):
+ Gtk.Application.do_startup(self)
+
+app = MyApplication()
+exit_status = app.run(sys.argv)
+sys.exit(exit_status)
diff --git a/platform-demos/C/samples/treeview_simple_liststore.py b/platform-demos/C/samples/treeview_simple_liststore.py
index 820a8ed..4af92b6 100644
--- a/platform-demos/C/samples/treeview_simple_liststore.py
+++ b/platform-demos/C/samples/treeview_simple_liststore.py
@@ -21,27 +21,26 @@ class MyWindow(Gtk.ApplicationWindow):
# the data in the model (three strings for each row, one for each column)
listmodel = Gtk.ListStore(str, str, str)
- # there is no insert_with_values() in Python, we use append
+ # append the values in the model
for i in range(len(phonebook)):
listmodel.append(phonebook[i])
# a treeview to see the data stored in the model
view = Gtk.TreeView(model=listmodel)
- # with columns - arguments of treeviewcolumn are:
- # column title, cell renderer, cell attributes
+ # for each column
for i in range(len(columns)):
+ # cellrenderer to render the text
cell = Gtk.CellRendererText()
# the text in the first column should be in boldface
if i == 0:
cell.props.weight_set=True
cell.props.weight=Pango.Weight.BOLD
- col = Gtk.TreeViewColumn(columns[i],
- cell,
- text=i)
+ # the column is created
+ col = Gtk.TreeViewColumn(columns[i], cell, text=i)
+ # and it is appended to the treeview
view.append_column(col)
-
- # when a row is selected, emit a signal
+ # when a row is selected, it emits a signal
view.get_selection().connect("changed", self.on_changed)
# the label we use to show the selection
@@ -50,9 +49,10 @@ class MyWindow(Gtk.ApplicationWindow):
# a grid to attach the widgets
grid = Gtk.Grid()
- grid.attach(view, 0, 0, 1, 1);
- grid.attach(self.label, 0, 1, 1, 1);
+ grid.attach(view, 0, 0, 1, 1)
+ grid.attach(self.label, 0, 1, 1, 1)
+ # attach the grid to the window
self.add(grid)
def on_changed(self, selection):
@@ -65,7 +65,7 @@ class MyWindow(Gtk.ApplicationWindow):
class MyApplication(Gtk.Application):
def __init__(self):
- Gtk.Application.__init__(self, application_id="org.example.treeview_simple_liststore")
+ Gtk.Application.__init__(self)
def do_activate(self):
win = MyWindow(self)
diff --git a/platform-demos/C/samples/treeview_treestore.py b/platform-demos/C/samples/treeview_treestore.py
new file mode 100644
index 0000000..4b7277c
--- /dev/null
+++ b/platform-demos/C/samples/treeview_treestore.py
@@ -0,0 +1,59 @@
+from gi.repository import Gtk
+from gi.repository import Pango
+import sys
+
+books = [["Tolstoy, Leo", "War and Peace", "Anna Karenina"],
+ ["Shakespeare, William", "Hamlet", "Macbeth", "Othello"],
+ ["Tolkien, J.R.R.", "The Lord of the Rings"]]
+
+class MyWindow(Gtk.ApplicationWindow):
+ def __init__(self, app):
+ Gtk.Window.__init__(self, title="Library", application=app)
+ self.set_default_size(250, 100)
+ self.set_border_width(10)
+
+ # the data are stored in the model
+ # create a treestore with one column
+ store = Gtk.TreeStore(str)
+ for i in range(len(books)):
+ # the iter piter is returned when appending the author
+ piter = store.append(None, [books[i][0]])
+ # append the books as children of the author
+ j = 1
+ while j < len(books[i]):
+ store.append(piter, [books[i][j]])
+ j += 1
+
+ # the treeview shows the model
+ # create a treeview on the model store
+ view = Gtk.TreeView()
+ view.set_model(store)
+
+ # the cellrenderer for the column - text
+ renderer_books = Gtk.CellRendererText()
+ # the column is created
+ column_books = Gtk.TreeViewColumn("Books by Author", renderer_books, text=0)
+ # and it is appended to the treeview
+ view.append_column(column_books)
+
+ # the books are sortable by author
+ column_books.set_sort_column_id(0)
+
+ # add the treeview to the window
+ self.add(view)
+
+
+class MyApplication(Gtk.Application):
+ def __init__(self):
+ Gtk.Application.__init__(self)
+
+ def do_activate(self):
+ win = MyWindow(self)
+ win.show_all()
+
+ def do_startup(self):
+ Gtk.Application.do_startup(self)
+
+app = MyApplication()
+exit_status = app.run(sys.argv)
+sys.exit(exit_status)
diff --git a/platform-demos/C/treeview_advanced_liststore.py.page b/platform-demos/C/treeview_advanced_liststore.py.page
new file mode 100644
index 0000000..500b5de
--- /dev/null
+++ b/platform-demos/C/treeview_advanced_liststore.py.page
@@ -0,0 +1,52 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<page xmlns="http://projectmallard.org/1.0/"
+ xmlns:xi="http://www.w3.org/2001/XInclude"
+ type="guide" style="task"
+ id="treeview_simple_liststore.py">
+ <info>
+ <link type="guide" xref="beginner.py#treeview"/>
+ <link type="seealso" xref="grid.py"/>
+ <link type="seealso" xref="label.py"/>
+ <link type="seealso" xref="button.py"/>
+ <revision version="0.1" date="2012-06-30" status="draft"/>
+
+ <credit type="author copyright">
+ <name>Marta Maria Casetti</name>
+ <email>mmcasetti gmail com</email>
+ <years>2012</years>
+ </credit>
+
+ <desc>A TreeView displaying a ListStore (more complex example)</desc>
+ </info>
+
+ <title>Simple Treeview with ListStore</title>
+ <media type="image" mime="image/png" src="media/treeview_simple_liststore.png"/>
+ <p>This TreeView displays a simple ListStore with the selection "changed" signal connected.</p>
+
+ <links type="section" />
+
+ <section id="code">
+ <title>Code used to generate this example</title>
+
+ <code mime="text/x-python" style="numbered"><xi:include href="samples/treeview_simple_liststore.py" parse="text"><xi:fallback/></xi:include></code>
+ </section>
+
+ <section id="methods">
+ <title>Useful methods for a TreeView widget</title>
+ <p>The TreeView widget is designed around a <em>Model/View/Controller</em> design. For more information, and for a list of useful methods for TreeView and the interface TreeModel, see <link xref="model-view-controller.py">here</link>.</p>
+ </section>
+
+ <section id="references">
+ <title>API References</title>
+ <p>In this sample we used the following:</p>
+ <list>
+ <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkTreeView.html">GtkTreeView</link></p></item>
+ <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkTreeModel.html">GtkTreeModel</link></p></item>
+ <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkListStore.html">GtkListStore</link></p></item>
+ <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkCellRendererText.html">GtkCellRendererText</link></p></item>
+ <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkTreeViewColumn.html">GtkTreeViewColumn</link></p></item>
+ <item><p><link href="http://git.gnome.org/browse/pygobject/tree/gi/overrides/Gtk.py">pygobject - Python bindings for GObject Introspection</link></p></item>
+ <item><p><link href="http://developer.gnome.org/pango/stable/pango-Fonts.html">Fonts</link></p></item>
+ </list>
+ </section>
+</page>
diff --git a/platform-demos/C/treeview_cellrenderertoggle.py.page b/platform-demos/C/treeview_cellrenderertoggle.py.page
new file mode 100644
index 0000000..2cdb46c
--- /dev/null
+++ b/platform-demos/C/treeview_cellrenderertoggle.py.page
@@ -0,0 +1,48 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<page xmlns="http://projectmallard.org/1.0/"
+ xmlns:xi="http://www.w3.org/2001/XInclude"
+ type="guide" style="task"
+ id="treeview_cellrenderertoggle.py">
+ <info>
+ <link type="guide" xref="beginner.py#treeview"/>
+ <revision version="0.1" date="2012-06-30" status="draft"/>
+
+ <credit type="author copyright">
+ <name>Marta Maria Casetti</name>
+ <email>mmcasetti gmail com</email>
+ <years>2012</years>
+ </credit>
+
+ <desc>A TreeView displaying a TreeStore (more complex example, with CellRendererToggle)</desc>
+ </info>
+
+ <title>Treeview with TreeStore</title>
+ <media type="image" mime="image/png" src="media/treeview_cellrenderertoggle.png"/>
+ <p>This TreeView displays a TreeStore with two columns, one of which is rendered as a toggle.</p>
+
+ <links type="section" />
+
+ <section id="code">
+ <title>Code used to generate this example</title>
+
+ <code mime="text/x-python" style="numbered"><xi:include href="samples/treeview_cellrenderertoggle.py" parse="text"><xi:fallback/></xi:include></code>
+ </section>
+
+ <section id="methods">
+ <title>Useful methods for a TreeView widget</title>
+ <p>The TreeView widget is designed around a <em>Model/View/Controller</em> design. For more information, and for a list of useful methods for TreeView and the interface TreeModel, see <link xref="model-view-controller.py">here</link>.</p>
+ </section>
+
+ <section id="references">
+ <title>API References</title>
+ <p>In this sample we used the following:</p>
+ <list>
+ <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkTreeView.html">GtkTreeView</link></p></item>
+ <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkTreeModel.html">GtkTreeModel</link></p></item>
+ <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkTreeStore.html">GtkTreeStore</link></p></item>
+ <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkCellRendererText.html">GtkCellRendererText</link></p></item>
+ <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkCellRendererToggle.html">GtkCellRendererToggle</link></p></item>
+ <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkTreeViewColumn.html">GtkTreeViewColumn</link></p></item>
+ </list>
+ </section>
+</page>
diff --git a/platform-demos/C/treeview_simple_liststore.py.page b/platform-demos/C/treeview_simple_liststore.py.page
index 1a86ba8..a2aa7d8 100644
--- a/platform-demos/C/treeview_simple_liststore.py.page
+++ b/platform-demos/C/treeview_simple_liststore.py.page
@@ -7,7 +7,7 @@
<link type="guide" xref="beginner.py#treeview"/>
<link type="seealso" xref="grid.py"/>
<link type="seealso" xref="label.py"/>
- <revision version="0.1" date="2012-06-02" status="draft"/>
+ <revision version="0.2" date="2012-06-30" status="draft"/>
<credit type="author copyright">
<name>Marta Maria Casetti</name>
@@ -15,22 +15,37 @@
<years>2012</years>
</credit>
- <desc>A widget can display any TreeModel implementation (lists and trees)</desc>
+ <desc>A TreeView displaying a ListStore (simpler example)</desc>
</info>
<title>Simple Treeview with ListStore</title>
<media type="image" mime="image/png" src="media/treeview_simple_liststore.png"/>
- <p>This TreeView displays a simple ListStore with the Selection "changed" signal connected.</p>
-
-<code mime="text/x-python" style="numbered"><xi:include href="samples/treeview_simple_liststore.py" parse="text"><xi:fallback/></xi:include></code>
-<p>
- In this sample we used the following:
-</p>
-<list>
- <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkTreeView.html">GtkTreeView</link></p></item>
- <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkListStore.html">GtkListStore</link></p></item>
- <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkTreeViewColumn.html">GtkTreeViewColumn</link></p></item>
- <item><p><link href="http://git.gnome.org/browse/pygobject/tree/gi/overrides/Gtk.py">pygobject - Python bindings for GObject Introspection</link></p></item>
- <item><p><link href="http://developer.gnome.org/pango/stable/pango-Fonts.html">Fonts</link></p></item>
-</list>
+ <p>This TreeView displays a simple ListStore with the selection "changed" signal connected.</p>
+
+ <links type="section" />
+
+ <section id="code">
+ <title>Code used to generate this example</title>
+
+ <code mime="text/x-python" style="numbered"><xi:include href="samples/treeview_simple_liststore.py" parse="text"><xi:fallback/></xi:include></code>
+ </section>
+
+ <section id="methods">
+ <title>Useful methods for a TreeView widget</title>
+ <p>The TreeView widget is designed around a <em>Model/View/Controller</em> design. For more information, and for a list of useful methods for TreeView and the interface TreeModel, see <link xref="model-view-controller.py">here</link>.</p>
+ </section>
+
+ <section id="references">
+ <title>API References</title>
+ <p>In this sample we used the following:</p>
+ <list>
+ <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkTreeView.html">GtkTreeView</link></p></item>
+ <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkTreeModel.html">GtkTreeModel</link></p></item>
+ <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkListStore.html">GtkListStore</link></p></item>
+ <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkCellRendererText.html">GtkCellRendererText</link></p></item>
+ <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkTreeViewColumn.html">GtkTreeViewColumn</link></p></item>
+ <item><p><link href="http://git.gnome.org/browse/pygobject/tree/gi/overrides/Gtk.py">pygobject - Python bindings for GObject Introspection</link></p></item>
+ <item><p><link href="http://developer.gnome.org/pango/stable/pango-Fonts.html">Fonts</link></p></item>
+ </list>
+ </section>
</page>
diff --git a/platform-demos/C/treeview_treestore.py.page b/platform-demos/C/treeview_treestore.py.page
new file mode 100644
index 0000000..870f6b2
--- /dev/null
+++ b/platform-demos/C/treeview_treestore.py.page
@@ -0,0 +1,47 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<page xmlns="http://projectmallard.org/1.0/"
+ xmlns:xi="http://www.w3.org/2001/XInclude"
+ type="guide" style="task"
+ id="treeview_treestore.py">
+ <info>
+ <link type="guide" xref="beginner.py#treeview"/>
+ <revision version="0.1" date="2012-06-30" status="draft"/>
+
+ <credit type="author copyright">
+ <name>Marta Maria Casetti</name>
+ <email>mmcasetti gmail com</email>
+ <years>2012</years>
+ </credit>
+
+ <desc>A TreeView displaying a TreeStore (simpler example)</desc>
+ </info>
+
+ <title>Treeview with TreeStore</title>
+ <media type="image" mime="image/png" src="media/treeview_treestore.png"/>
+ <p>This TreeView displays a TreeStore.</p>
+
+ <links type="section" />
+
+ <section id="code">
+ <title>Code used to generate this example</title>
+
+ <code mime="text/x-python" style="numbered"><xi:include href="samples/treeview_treestore.py" parse="text"><xi:fallback/></xi:include></code>
+ </section>
+
+ <section id="methods">
+ <title>Useful methods for a TreeView widget</title>
+ <p>The TreeView widget is designed around a <em>Model/View/Controller</em> design. For more information, and for a list of useful methods for TreeView and the interface TreeModel, see <link xref="model-view-controller.py">here</link>.</p>
+ </section>
+
+ <section id="references">
+ <title>API References</title>
+ <p>In this sample we used the following:</p>
+ <list>
+ <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkTreeView.html">GtkTreeView</link></p></item>
+ <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkTreeModel.html">GtkTreeModel</link></p></item>
+ <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkTreeStore.html">GtkTreeStore</link></p></item>
+ <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkCellRendererText.html">GtkCellRendererText</link></p></item>
+ <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkTreeViewColumn.html">GtkTreeViewColumn</link></p></item>
+ </list>
+ </section>
+</page>
diff --git a/platform-demos/Makefile.am b/platform-demos/Makefile.am
index 44e2789..7287d98 100644
--- a/platform-demos/Makefile.am
+++ b/platform-demos/Makefile.am
@@ -124,8 +124,11 @@ demo_sources = \
samples/toolbar.vala \
samples/toolbar_builder.ui \
samples/toolbar_builder.vala \
+ samples/treeview_advanced_liststore.py \
+ samples/treeview_cellrenderertoggle.py \
samples/treeview_simple_liststore.py \
samples/treeview_simple_liststore.vala \
+ samples/treeview_treestore.py \
samples/window.c \
samples/window.js \
samples/window.py \
@@ -192,7 +195,10 @@ DOC_FIGURES = \
media/textviewpenguinchat.png \
media/togglebutton.png \
media/toolbar.png \
+ media/treeview_advanced_liststore.png \
+ media/treeview_cellrenderertoggle.png \
media/treeview_simple_liststore.png \
+ media/treeview_treestore.png \
media/ubuntu.png \
media/weatherAppJs.png \
media/window.png \
@@ -278,6 +284,7 @@ DOC_PAGES = \
messagedialog.js.page \
messagedialog.py.page \
messagedialog.vala.page \
+ model-view-controller.py.page \
photo-wall.c.page \
progressbar.c.page \
progressbar.js.page \
@@ -324,8 +331,11 @@ DOC_PAGES = \
toolbar.py.page \
toolbar.vala.page \
toolbar_builder.vala.page \
+ treeview_advanced_liststore.py.page \
+ treeview_cellrenderertoggle.py.page \
treeview_simple_liststore.py.page \
treeview_simple_liststore.vala.page \
+ treeview_treestore.py.page \
translate.page \
vala.page \
weatherApp.js.page \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]