limiting text input in Tkinter Entry widget

Fredrik Lundh fredrik at pythonware.com
Sun Feb 22 17:39:34 EST 2004


Otto Krüse wrote:

> I'm building a GUI in which I want, amongst other things, for people to
> fill in there postal code. The postal codes of my country (Holland) are
> in this format: 1234 AB
>
> So for the input I use two entry widgets, one of a length of
> (characters) for the numbers and one of lenght 2 for the letters. What I
> don't like is that although the visible part of the widgets thus are 4
> and 2 characters, users can actually input more characters. They could
> for example input 12345 abcd. I want to make that impossible.
>
> Does anyone know a way to limit the amount of characters an entry widget
> can take? Is there an easy option to set for this or does this problem
> require some python code?

http://effbot.org/zone/tkinter-entry-validate.htm

</F>







More information about the Python-list mailing list