Re: [pygtk] examples of gtk new tree/list widget stuff?



On Wed, 25 Apr 2001 skip pobox com wrote:

>
> Are there any readable examples of the new gtk tree/list stuff floating
> around?  The gtk/tests/testgtk.c files still uses the old stuff and the
> various gtk/tests/testtree*.c files don't really qualify as "readable",
> especially since I have no mental model of how this is supposed to work.
> Initially, I'm not interested in all the fancy bells and whistles these
> widgets support.  I just want to create a single-column list and add and
> remove items from it.  Python or C is fine.

Take a look at the create_list() function in
examples/pygtk-demo/pygtk-demo.py distributed with pygtk.  It creates a
simple list using the tree widget.

The basic model for using the new widget is something like this:

- create a GtkTreeModel.  The GtkListStore and GtkTreeStore are two
  models you might want to use.

  A model consists of a tree (or in the degenerate case, a list) of nodes.
  Each node has a number of columns.

- Create one or more GtkTreeView widgets.  These are views of the model.

- add GtkTreeViewColumn objects to the views.  You need to specify a
  GtkCellRenderer object for each TreeViewColumn.  The cell renderer uses
  a number of properties to render a cell in the view (such as the text to
  display, foreground and background colours, etc).  Each of these
  properties can be mapped onto a column in the model (so for instance,
  you could have a model that had one column that gave the text to display
  in the view, and one column to give the foregeround colour).

Hopefully this is enough to get started with the tree widget.

James.

-- 
Email: james daa com au
WWW:   http://www.daa.com.au/~james/






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]