On Sat, Dec 27, 2008 at 09:59:55AM +0100, Alessandro Dentella wrote: > > > 1. the explanation is exactly the same as for "emit_stop_by_name": which > > > is the difference? > > > > > > > > They are the same. > > ok, I guess some hystorical reason... > > > Some signals provide an explicit means of stopping the signal emission > > using a return value from a handler. The "clicked" handler is not > > supposed to provide a return value so returning True does nothing.
This sentenced induced me to think that "stop_emission" could be used always while return True only by those signals that support it. On the contrary in the following example I try to stop emission of key-press-event from within the 'edited' callback back to the treeview callback and it seems not to work. I connected with Tab from the treeview a callback that shiftws the cell to be edited, but I'd like to stop it under some conditions from within editabel callback. it's enought to "return True" (Line #### 59) and it works but it does not work instead the line: self.treeview.emit_stop_by_name('key-press-event') Did I mis-interpret the signal? sandro *:-) #!/usr/bin/python import gtk import gtk.gdk import gobject class Tree(object): def __init__(self): self.w = gtk.Window() self.w.connect('destroy', gtk.main_quit) self.treeview = gtk.TreeView() self.w.add(self.treeview) self.model = gtk.ListStore(str, str) self.treeview.set_model(self.model) self.col1, cell1 = self.add_col('col1', 0) self.col2, cell2 = self.add_col('col2', 1) self.treeview.connect('key-press-event', self.on_tree_key_press) cell1.connect('editing-started', self.text_editing_started_cb) cell1.connect('edited', self.text_edited_cb ) self.fill_model() self.w.show_all() def on_tree_key_press(self, widget, event): ksym = gtk.gdk.keyval_name(event.keyval) if ksym == "Tab": print "Tab from treeview" path, col = self.treeview.get_cursor() #self.treeview.set_cursor(path, self.col2, True) self.tag = gobject.idle_add(self.treeview.set_cursor, path, self.col2, True) def add_col(self, label, pos): cell = gtk.CellRendererText() cell.set_property('editable', True) cell.set_property('editable-set', True) col = gtk.TreeViewColumn(label) col.pack_start(cell) col.add_attribute(cell, 'text', pos ) col.set_expand(True) self.treeview.append_column(col) return col, cell def text_editing_started_cb(self, cell, editable, path): #editable.connect('editing-done', self.editing_done_cb) editable.connect('key-press-event', self.on_editable_cb) def text_edited_cb(self, cell, editable, path): #self.treeview.stop_emission pass def on_editable_cb(self, widget, event): ksym = gtk.gdk.keyval_name(event.keyval) if ksym == "Tab": print "Tab from editable" #return True #### line 59 #gobject.source_remove(self.tag) widget.stop_emission('key-press-event') #self.treeview.stop_emission('key-press-event') self.treeview.emit_stop_by_name('key-press-event') # def editing_done_cb(self, celleditable): # if celleditable.get_text() == 'x': # celleditable.stop_emission('remove-widget') def fill_model(self): for i in ('uno', 'due', 'tre'): self.model.append([i *3, i*2]) t = Tree() t.w.resize(400, 200) #t.treeview.set_cursor(0, t.col2, True) try: gtk.main() except KeyboardInterrupt, e: pass _______________________________________________ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/