[pygtk] how to connect a TreeModel with View

2001-12-05 Thread Robert Nikander

Hi,

I am trying to use the new TreeModel/View stuff in the latest pygtk 
(1.99.5).  In short, I need to know how to 'notify' the view when my 
model is updated.  I have copied from the example that shows a class 
that subclasses gtk.GenericTreeModel and overrides a bunch of on_* 
methods.   Now, my database gets updated and I want to signal the 
attached tree-view.  I tried:

 self.emit('row-inserted', new_iter, new_iter)

but got:

Traceback (most recent call last):
   File ./gtktest.py, line 105, in change_tree
 tree_model.add_row()
   File ./gtktest.py, line 19, in add_row
 self.emit('row-inserted', new_iter, new_iter)
TypeError: could not convert type tuple to GtkTreeIter required for 
parameter 1

I tried subclassing TreeIter and got the NotImplemented exception.

So, how are people using TreeModels?

Thanks,
Rob
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk



Re: [pygtk] how to connect a TreeModel with View

2001-12-05 Thread Matt Wilson

The python implementation of a GtkTreeModel uses tuples as the iter.
Build up the path to the new node (which is also a tuple which lists
the nodes to get to the updated node), and pass it as both the path
and the iter.

Cheers,

Matt

On Wed, Dec 05, 2001 at 10:14:33AM -0500, Robert Nikander wrote:
 Hi,
 
 I am trying to use the new TreeModel/View stuff in the latest pygtk 
 (1.99.5).  In short, I need to know how to 'notify' the view when my 
 model is updated.  I have copied from the example that shows a class 
 that subclasses gtk.GenericTreeModel and overrides a bunch of on_* 
 methods.   Now, my database gets updated and I want to signal the 
 attached tree-view.  I tried:
 
  self.emit('row-inserted', new_iter, new_iter)
 
 but got:
 
 Traceback (most recent call last):
File ./gtktest.py, line 105, in change_tree
  tree_model.add_row()
File ./gtktest.py, line 19, in add_row
  self.emit('row-inserted', new_iter, new_iter)
 TypeError: could not convert type tuple to GtkTreeIter required for 
 parameter 1
 
 I tried subclassing TreeIter and got the NotImplemented exception.
 
 So, how are people using TreeModels?
 
 Thanks,
 Rob
 ___
 pygtk mailing list   [EMAIL PROTECTED]
 http://www.daa.com.au/mailman/listinfo/pygtk
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk



Re: [pygtk] how to connect a TreeModel with View

2001-12-05 Thread James Henstridge

Robert Nikander wrote:

 Hi,

 I am trying to use the new TreeModel/View stuff in the latest pygtk 
 (1.99.5).  In short, I need to know how to 'notify' the view when my 
 model is updated.  I have copied from the example that shows a class 
 that subclasses gtk.GenericTreeModel and overrides a bunch of on_* 
 methods.   Now, my database gets updated and I want to signal the 
 attached tree-view.  I tried:

 self.emit('row-inserted', new_iter, new_iter)

 but got:

 Traceback (most recent call last):
   File ./gtktest.py, line 105, in change_tree
 tree_model.add_row()
   File ./gtktest.py, line 19, in add_row
 self.emit('row-inserted', new_iter, new_iter)
 TypeError: could not convert type tuple to GtkTreeIter required for 
 parameter 1

 I tried subclassing TreeIter and got the NotImplemented exception.

 So, how are people using TreeModels?

The GenericTreeModel class has a number of limitations (you just ran 
into some).  For 0.99.5, you probably can't do what you want.  Note that 
GenericTreeModel will leak lots of references (and can't really be fixed).

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk



Re: [pygtk] how to connect a TreeModel with View

2001-12-05 Thread Matt Wilson

The constructor for TreeStore is like this:

treestore = gtk.TreeStore(gobject.TYPE_STRING)

No need to pass in a number.

Cheers,

Matt

On Wed, Dec 05, 2001 at 12:42:45PM -0500, Robert Nikander wrote:
 Well I don't care too much about writing my own TreeModel.  Is there 
 another way to put a tree in the GUI short of going back to .0.6.8?  
 What about gtk.TreeStore?
 
 I tried:
 
 ts = gtk.TreeStore(1, gobject.TYPE_STRING)
 
 but any method call on it yields:
 
 
   (pid:7622): GLib-GObject-WARNING **: invalid cast from (NULL) pointer 
 to `GtkTreeModel'
 
   (pid:7622): Gtk-CRITICAL **: file gtktreemodel.c: line 605 
 (gtk_tree_model_get_n_columns): assertion `GTK_IS_TREE_MODEL 
 (tree_model)' failed
 
 Actually the GenericTreeModel may work okay for my purposes as I don't 
 care about memory leaks all that much (I am just prototyping) and I can 
 update the gui by reexpanding the tree.
 
 
 Thanks,
 Rob
 ___
 pygtk mailing list   [EMAIL PROTECTED]
 http://www.daa.com.au/mailman/listinfo/pygtk
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk



Re: [pygtk] how to connect a TreeModel with View

2001-12-05 Thread James Henstridge

Robert Nikander wrote:

 Well I don't care too much about writing my own TreeModel.  Is there 
 another way to put a tree in the GUI short of going back to .0.6.8?  
 What about gtk.TreeStore?

 I tried:

 ts = gtk.TreeStore(1, gobject.TYPE_STRING) 

get rid of the 1.  The TreeStore constructor takes a variable number of 
arguments giving the column types (no column count as the first arg). 
 The fact that it accepted 1 as an arg is an error.

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk