ons 2003-01-15 klockan 13.05 skrev Roberto Cavada:
> Hi,
> the GTK+ FAQ states that user-defined data can be stored inside a
> GtkTreeModel via a hidden column.
> How can I associate each row in the TreeModel with a user-defined
> python class instance? If I use an hidden column in the model, what's
> the type for that column?
Add another row in the Model, but don't assign a TreeViewColumn too it.
for example:
COLUMN_NAME=0
COLUMN_ADDRESS=1
COLUMN_PHONE=2
COLUMN_DATA=3
model = gtk.ListStore(gobject.TYPE_STRING, # name
gobject.TYPE_STRING, # address
gobject.TYPE_INT, # phone number
gobject.TYPE_PYOBJECT) # custom
... Create TreeViewColumn for all columns except the last ...
iter = model.append()
model.set(iter, COLUMN_NAME, "John Doe",
COLUMN_ADDRESS, "Foostreet 12",
COLUMN_PHONE, "12345678",
COLUMN_DATA, custom)
(and model.get(iter, COLUMN_DATA) to retrieve)
custom can here be any kind of object in Python (string, int, float,
class/type instance etc)
--
Johan Dahlin <[EMAIL PROTECTED]>
Async Open Source
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/