Cancel editing on a gtk.CellRendererText

View: New views
2 Messages — Rating Filter:   Alert me  

Cancel editing on a gtk.CellRendererText

by Seth Mahoney :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I've got a TreeView that displays different kinds of data - basically book citations and plain text - in a sort of outline format.  I'd like the plain text to be editable, and the book citations to be noneditable, but I can't seem to figure out how to cancel editing.  The first column of my TreeModel contains the text to be displayed, and the second column contains xml data, which isn't displayed, but is used for a variety of purposes, including identifying the type of data.  The callback correctly prints "called!" when I try to edit a citation, but doesn't cancel the edit.  I've also tried calling editing_canceled(), but that doesn't work either.  Here's what my callback, connected to "editing-started", looks like right now:

    def outline_edit_start_cb(self, cell, editable, path, model):
        my_iter = model.get_iter_from_string(path)
        if model.get_value(my_iter, 1).tag == "cite":
            print "called!"   
            cell.stop_editing(True)
            return True
        return False

Any help would be appreciated.



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

Parent Message unknown Re: Cancel editing on a gtk.CellRendererText

by Seth Mahoney-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm not sure this is what I'm looking for.  I only have one visible column, with one gtk.CellRendererText managing the whole thing.  I need a way to either get at the individual cells within the column and set the editable property there, or to cancel editing after it has begun if the data in the second (invisible) column meets certain criteria.  Thanks for the tip though.

--Seth

On Wed, Jul 16, 2008 at 4:49 PM, Alessandro Dentella <sandro@...> wrote:
> I've got a TreeView that displays different kinds of data - basically book
> citations and plain text - in a sort of outline format.  I'd like the
> plain text to be editable, and the book citations to be noneditable, but I
> can't seem to figure out how to cancel editing.



you can set the cell as non editable. I have code as:

    if not self.fields[v]['edit']:
        try:
            cell.set_property('editable', False)
        except:
            cell.set_property('sensitive', False)

i don't remeber why I try both editable & sensitive. I guess it depends on
the type of cell renderer.

sandro
*:-)




_______________________________________________
pygtk mailing list   pygtk@...
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
LightInTheBox - Buy quality products at wholesale price