After searching for a long time I found a solution (pretty simple) to move between cells of a treeview grid using Tab key and mantaining cells in edit mode.
Now I've got a problem: cell edit confirmation happens only after pressing Enter key. If I press Tab key a editing_canceled event appears to be triggered.
How to solve it? How to permit the data confirmation also on tab key press?
This is my event handler for treeview key-press-event:
def key_tree_Tab(self, treeview, event,namewidget):
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 event.keyval==65289:
if colnum + 1 < len(columns):
next_column = columns[colnum + 1]
treeview.set_cursor(path,next_column,start_editing=True)
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]
treeview.set_cursor(path,next_column,start_editing=True)
return True
Thanks to all!!!!
I know this thread is long ago. I tried your code with current version of Python3 and Gtk3 and does not work. It works only with new rows. The existing rows do not tab to next cell. If I add "return True" then every cell can Tab even with existing cells, but none gets updated.