Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #28213
| References | (3 earlier) <k1qkpa$d1g$1@dont-email.me> <hW40s.4177$905.750@fx27.am4> <624248hoth2ih6bu6jvnvehokbenn0a555@invalid.netcom.com> <CAJ6cK1aM_4Num7V6=hxrLLLs0-VpzXh42v+jWz5x9xcN-3XXPQ@mail.gmail.com> <k1so4h$vlq$1@ger.gmane.org> |
|---|---|
| Date | 2012-09-01 13:56 +0100 |
| Subject | Re: Tkinter bug in Entry widgets on OS X |
| From | Arnaud Delobelle <arnodel@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.33.1346504196.27098.python-list@python.org> (permalink) |
On 1 September 2012 11:30, Peter Otten <__peter__@web.de> wrote:
> Arnaud Delobelle wrote:
>> It would be good if I could intercept the key press event and cancel its
>> action on the Entry widget. It's easy to intercept the key event, but I
>> haven't found out how to prevent the funny characters from being inserted
>> into the Entry widget input area.
>
> Untested as I have no Mac:
>
> import Tkinter as tk
>
> def suppress(event):
> if event.keycode in {111, 116}:
> print "ignoring", event.keycode
> return "break"
> print event.keycode, "accepted"
>
> root = tk.Tk()
> entry = tk.Entry(root)
> entry.bind("<Key>", suppress)
> entry.pack()
>
> root.mainloop()
This works fine!
return "break" is the piece of knowledge that I was missing. Thanks a
lot! In fact I lied a bit in my original message - I do use the UP
and DOWN arrows on one Entry widget for navigating its command
history. To do this I was binding the "<Up>" and "<Down>" events to a
function, which simply has to return "break" to work around the bug.
On other Entry widgets, I just bind "<Up>" and "<Down>" to a suppress
function which simply returns "break".
>> I've struggled to find good tkinter
>> docs on the web.
>
> For my (basic) needs I keep coming back to
>
> http://infohost.nmt.edu/tcc/help/pubs/tkinter/
Thanks for the link. I was using the docs on effbot which are nice
but probably incomplete (and old).
I guess I should flag up this bug but I don't even know if it's a
Python or Tk problem and have little time or expertise to investigate.
--
Arnaud
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Tkinter bug in Entry widgets on OS X Arnaud Delobelle <arnodel@gmail.com> - 2012-08-31 11:18 +0100
Re: Tkinter bug in Entry widgets on OS X Kevin Walzer <kw@codebykevin.com> - 2012-08-31 10:25 -0400
Re: Tkinter bug in Entry widgets on OS X Arnaud Delobelle <arnodel@gmail.com> - 2012-08-31 16:18 +0100
Re: Tkinter bug in Entry widgets on OS X Kevin Walzer <kw@codebykevin.com> - 2012-08-31 11:21 -0400
Re: Tkinter bug in Entry widgets on OS X Alister <alister.ware@ntlworld.com> - 2012-08-31 15:41 +0000
Re: Tkinter bug in Entry widgets on OS X Arnaud Delobelle <arnodel@gmail.com> - 2012-08-31 20:05 +0100
Re: Tkinter bug in Entry widgets on OS X Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-08-31 15:30 -0400
Re: Tkinter bug in Entry widgets on OS X Peter Otten <__peter__@web.de> - 2012-09-01 12:30 +0200
Re: Tkinter bug in Entry widgets on OS X Arnaud Delobelle <arnodel@gmail.com> - 2012-09-01 13:56 +0100
Re: Tkinter bug in Entry widgets on OS X "Russell E. Owen" <rowen@uw.edu> - 2012-09-13 13:33 -0700
csiph-web