[pygtk] gtk.Entry / gtk.Completion behavior -- can I change it?

Chris Gonnerman chris.gonnerman at newcenturycomputers.net
Sun Mar 5 00:19:47 WST 2006


Danny Milosavljevic wrote:
> I tried with gtk+ 2.8.9 and there I confirm that it works strangely
> (assuming you mean gtk.EntryCompletion). 
Oops, yes, I do mean gtk.EntryCompletion.
> Typing some prefix into the entry causes 
> - the listbox to pop up
> - the first item to be selected <- this one drives me nuts, can't it
> stop getting in my way?
>
> Then press down arrow and press tab, indeed, it takes the wrong one...
On my system, tab selects nothing; the typed text is allowed
to remain as is.
> I'd file a bug with gtk...
I'm considering it.

Logically, I should be able to:

    1. Return True from the key-press-event handler for the
       EntryCompletion when a Tab is detected and an item in
       the completion list is highlighted, so that the Tab
       is ignored,
    2. In the same handler, synthesize Return and then Tab
       events in sequence, so that the highlighted item is
       inserted into the Entry before focus moves.

Of course, the handler must not create a loop in this
situation; some sort of flag might be used to prevent the
synthetic Tab from triggering the process all over again.

I'm unsure of the "correct" way to synthesize keyboard events.
And, of course, there's always the possibility that this kind
of arrangement might backfire on me... I'm a 20+ year pro at
console applications but I've only been doing GUI stuff for a
handful of years.

Thanks for your advice.

-- Chris.



More information about the pygtk mailing list