[pygtk] making a editable treeview stay in edit mode
Alessandro Dentella
sandro at e-den.it
Fri Jun 12 16:44:40 WST 2009
> The idea here that hitting tab, back-tab, up-arrow or down-arrow move the cell
> being edited and not leave edit mode. I like the treeview because the list being
I use this code as callback of 'key-press-event' on Tab to achieve what you
are looking for.
The key ise 'treeview.set_cursor', that lets you say if you want to want to
get into editing mode::
def set_cursor(path, focus_column=None, start_editing=False)
the example is more complicated than you need, as I onnly use editing mode
if the column represents an editable data and I call self.get_direct_edit for that.
def key_tree_Tab(self, treeview, event, data):
path, col = treeview.get_cursor()
## only visible columns!!
columns = [c for c in treeview.get_columns() if c.get_visible()]
colnum = columns.index(col)
if colnum + 1 < len(columns):
next_column = columns[colnum + 1]
next_field_name = next_column.get_data('field_name')
gobject.idle_add(treeview.set_cursor, path,
next_column, self.get_direct_edit(next_field_name) )
else:
tmodel = treeview.get_model()
titer = tmodel.iter_next(tmodel.get_iter(path))
if titer is None:
titer = tmodel.get_iter_first()
path = tmodel.get_path(titer)
next_column = columns[0]
next_field_name = next_column.get_data('field_name')
gobject.idle_add(self.treeview.set_cursor, path, next_column,
self.get_direct_edit(next_field_name) )
return False
sandro
*:-)
--
Sandro Dentella *:-)
http://sqlkit.argolinux.org SQLkit home page - PyGTK/python/sqlalchemy
More information about the pygtk
mailing list