views:

13

answers:

0

I have a TreeView with a CellRendererCombo in it. Currently, I've connected the editing signal to a function which changes the underlying model and does some other actions based on the new value. However, this is annoying for the user. Dropping down the list and clicking on a new item does not seem to cause editing to "finish". Instead the user has to hit 'enter' or click on some other interface element.

So far I've come up with this ugly hack, where rendered is the gtk.CellRendererCombo in question. The thunk is cause this code is in a loop and curCE has to be unique per iteration..

def thunk():
    curCE = [None]
    def edit_start(cr, editable, path):
        curCE[0] = editable
    def _changed(cr, path, new_iter):
        if curCE[0] is None:
            print "I'm pretty sure CE shouldn't be none here"
            return
        curCE[0].editing_done()
        curCE[0] = None
    renderer.connect("editing-started", edit_start)
    renderer.connect("changed", _changed)
thunk()