2008-03-03
PyGTK Tab-Completion
PyGTK – EntryCompletion hacked up to give nicer tab-completion (PasteBin.ca) (GitHub)
While working on a batch organizing tool, I found out the hard way that GTK’s EntryCompletion is not meant for people who want speed. (It’s a memory aid, not a speed aid) I also couldn’t just switch to PyQt or wxPython because they all do basically the same thing.
As such, I hacked the GTK auto-complete up a bit so that it behaves more like shell auto-complete. (It doesn’t do anything until you hit Tab. When you do, if there’s one match, it’s completed. If there are multiple matches, it pops open the normal auto-complete list so you can pick one.
Hope this help someone. I know I would have liked to find this in my Google results.
Update: If you’d like to preserve normal tab behaviour when the box is empty, just change line 28 to if event.keyval == KEY_TAB and self.get_text():. Of course, make sure you explain the behaviour and provide some sort of workaround for tabbing when the field isn’t empty. (In my app, pressing enter to submit the contents and clear the field is a perfectly acceptable solution)

This work, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.

















Recent Links Tagged With "pygtk" - JabberTags said,
2009-02-24 at 21:04
[...] for a good guild web site are webmaster skills or maybe Saved by maxwell3947 on Sun 15-2-2009 PyGTK Tab-Completion Saved by interactivar on Sat 14-2-2009 About « Project Hamster Saved by VickiA on Wed 11-2-2009 [...]