tkinter absorb chars

Jeff Epler jepler at unpythonic.net
Thu Mar 3 17:33:03 CET 2005


On Wed, Mar 02, 2005 at 04:58:03PM -0600, phil wrote:
> Sorry for the repost, but moderator
> jeld the last one,

We saw both posts.

> In a Tkinter entry field (or Pmw entry)
> how could I eat charactres?

create a binding on the widget for the particular character you want to
treat specially.  If you want to suppress that character, return the
string "break" from the binding.  Example:

from Tkinter import *
t = Tkinter.Tk()
e = Tkinter.Entry(t); e.pack()
e.bind("x", lambda event: "break")

Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20050303/e692e13e/attachment.pgp>


More information about the Python-list mailing list