I am connected to the cell renderer's 'edited' signal. Unfortunately that doesn't tell me if the user is in the middle of editing something. Nor does it allow me to interact with the Entry while the user is editing the cell.

I needed to set up a filter on the Entry that was created to limit the text that was entered in the edited cell (i.e. I only wanted to allow numbers in a numeric column). Since there was no other way that I could find to get a hold of the Entry to make a connection to the 'insert-text' signal to attach the filter, this also allowed me to do that.

James

Thomas Mills Hinkle wrote:
On 4/22/05, James Pelletier <[EMAIL PROTECTED]> wrote:

I have found no good way of accessing the entry field of a tree view. In
my case, I needed to know if any cell was being edited, so I could save
the change before saving the contents of the store. I was able to come
up with a pretty heinous hack:


I think what you want to do is connect to the "edited" signal of the
cell renderer.

I do the following when I create my view:
renderer.set_property('editable',True)
# I pass the column number at this point to my renderer
# you might also want to pass your treemodel as a parameter
renderer.connect('edited',tree_edited_cb, column_number)
column = gtk.TreeViewColumn('My Label',renderer,text=my_column_number)

...

def tree_edited_cb (renderer, path, new_text, column_number):
"""renderer = the renderer that produced this signal
path = a string with my path in it
new_text = the new text the user typed
column_number (I passed this as a user parameter when I attached the callback)
"""
indices = path.split(":")
path_tuple = tuple(map(int,indices))
store = ???
# presumably you have a convenient way to get your tree model
# either as part of self if this is a method somewhere or as a user
# parameter you pass to this callback
treeiter = store.get_iter(path_tuple)
# set the text to whatever the user entered
store.set_value(treeiter,new_text)


Hope this helps :)

Look here for more details:
http://www.moeraki.com/pygtktutorial/pygtk2tutorial/sec-CellRenderers.html

Tom

_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to