- Art Haas arranged a host of electrons thusly: - > > I'm still working the entry box validation, and for now I'm trying to > stick with the approach of intercepting the insert-text signal. I've [snip]
Caveat: I've not been using PyGTK for too long myself, but I've stumbled on something which seems to work. After doing a bunch of reading (starting with the FAQ entry at http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq14.005.htp, which isn't entirely applicable, as it appears to be for the GTK1 version) I arrived at the following solution. It works quite well for me. def on_text_insert(self, entry, text, length, *args): entry.stop_emission('insert-text') entry.handler_block(self.handler_ids['insert-text']) pos = entry.get_position() print text entry.insert_text(text, pos) # more stuff required here, no doubt, for autocompletion & such gtk.idle_add(lambda: entry.set_position(pos + length)) entry.handler_unblock(self.handler_ids['insert-text']) return 0 Where handler_ids is just a place where I stash the return values of the connect(...) calls for later reference. Setting the position of the cursor just plain doesn't work from within the signal handler. Or I couldn't find any way to make it do so. I've experimented with using gtk.timeout_add as well as gtk.idle_add, but idle_add seems to work better with slow network links (sometimes individual characters would come out reversed using timeout_add). I'm still unclear as to whether I should be return gtk.FALSE or just a plain old false value from on_text_inserted to tell gtk to not propagate the signal further. It might not matter, either. Doing it this way seems to work for me. peace, ah -- The only exercise some people get is jumping to conclusions, running down their friends, side-stepping responsibility, and pushing their luck. _______________________________________________ pygtk mailing list [EMAIL PROTECTED] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
