Re: Problem about CellRendererText
- From: Giuseppe Penone <giuspen gmail com>
- To: Ming-ching Chiu <percle gmail com>
- Cc: gtkmm-list gnome org
- Subject: Re: Problem about CellRendererText
- Date: Wed, 29 Aug 2012 12:11:15 +0300
Hi,
I had a similar problem in the note taking application I'm writing
www.giuspen.com/cherrytreeIn that application you can insert the so called tables which are merely tree views with editable cells.
The best solution that I found is that after you enter value in a cell, click enter (or down) and automatically the
value is saved and the focus moves to the following cell (or first in the next row).
If you click up the result is the same but the move is to the former cell.
Cherrytree is written in python anyway.
What you need to look to is the file modules/tablez.py and the functions are mainly:
def on_key_press_table_cell(self, widget, event, path, model, col_num):
"""Catches Table Cell key presses"""
keyname = gtk.gdk.keyval_name(event.keyval)
if event.state & gtk.gdk.SHIFT_MASK:
pass
elif event.state & gtk.gdk.MOD1_MASK:
pass
elif event.state & gtk.gdk.CONTROL_MASK:
pass
else:
if keyname in ["Return", "Up", "Down"]:
if model[path][col_num] != widget.get_text():
model[path][col_num] = widget.get_text()
self.dad.update_window_save_needed("nbuf", True)
if keyname == "Up":
if col_num > 0:
next_col_num = col_num - 1
next_path = path
else:
next_iter = None
next_path = model.get_path(model.get_iter(path))
while not next_iter and next_path[0] > 0:
node_path_list = list(next_path)
node_path_list[0] -= 1
next_path = tuple(node_path_list)
next_iter = model.get_iter(next_path)
#next_iter = model.iter_next(model.get_iter(path))
if not next_iter: return
next_path = model.get_path(next_iter)
next_col_num = self.table_columns-1
else:
if col_num < self.table_columns-1:
next_col_num = col_num + 1
next_path = path
else:
next_iter = model.iter_next(model.get_iter(path))
if not next_iter: return
next_path = model.get_path(next_iter)
next_col_num = 0
#print "(path, col_num) = (%s, %s)" % (path, col_num)
#print "(next_path, next_col_num) = (%s, %s)" % (next_path, next_col_num)
next_column = self.curr_table_anchor.treeview.get_columns()[next_col_num]
self.curr_table_anchor.treeview.set_cursor_on_cell(next_path,
focus_column=next_column,
focus_cell=next_column.get_cell_renderers()[0],
start_editing=True)
def on_table_cell_editing_started(self, cell, editable, path, model, col_num):
"""A Table Cell is going to be Edited"""
if isinstance(editable, gtk.Entry):
editable.connect('key_press_event', self.on_key_press_table_cell, path, model, col_num)
def on_table_cell_edited(self, cell, path, new_text, model, col_num):
"""A Table Cell has been Edited"""
if model[path][col_num] != new_text:
model[path][col_num] = new_text
HTH, regards,
Giuseppe.
On Tue, Aug 28, 2012 at 11:50 PM, Ming-ching Chiu
<percle gmail com> wrote:
Hi,
Right now in my Tree View I have multiple editable cells in each row. However, to fill in all the cells, I have to click on one cell, enter the data, and then either hit return or click somewhere else to move the focus out of the cell, and then click the next cell which I want to enter data. If I click on the second cell right after entering data in the first cell without moving the focus out of it, the focus will move directly to the second cell and the data I just entered in the first cell is gone. Is there anyway to solve this problem? Thanks
Best,
Ming-ching
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
https://mail.gnome.org/mailman/listinfo/gtkmm-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]