[pygtk] Re:dynamic model in treeview edited signal callback?
Junichi Kawanishi
jkani4 at gmail.com
Wed Mar 12 20:21:20 WST 2008
Hi, Darren Hart.
I think your code is a simplest solution, excluding arguments 'model_bad' and 'column'.
The reason why I think so, the variable 'widget' is an instance variable of your class, and we
can access it from every instance method.
By the way, we can change the argument passed to connect().
Keep the return value from connect(), disconnect the signal, and connect the same
sinal again with another argument.
( In your case, another argument means project_store.)
regards,
-----
kani
> class TaskFilterListView(WidgetWrapper):
> def __init__(self, widget, context_store, project_store):
> WidgetWrapper.__init__(self, widget)
> self.context_store = context_store
> self.project_store = project_store
> self.widget.set_model(self.context_store)
>
> # setup the column and cell renderer
> self.tvcolumn0 = gtk.TreeViewColumn()
> self.cell0 = gtk.CellRendererText()
> self.cell0.set_property('editable', True)
> self.cell0.connect('edited', self.on_filter_edited,
> self.widget.get_model(), 0)
> self.tvcolumn0.pack_start(self.cell0, False)
> self.tvcolumn0.set_cell_data_func(self.cell0, self.data_func, "data")
> self.widget.append_column(self.tvcolumn0)
>
> def filter_by_context(self):
> self.widget.set_model(self.context_store)
>
> def filter_by_project(self):
> self.widget.set_model(self.project_store)
>
> def on_filter_edited(self, cell, path, new_text, model_bad, column):
> model = self.widget.get_model()
> model[path][column].title = new_text
More information about the pygtk
mailing list