Dec-21-2022, 06:50 AM
I'm writing a program in Tkinter.
One page is a form, where the user inputs various values.
How do I limit an Entry field to a specific size?
For example, I use the following code, so that the user can put in their zip code:
There is a "Proceed" Button, which will write all the input to a file, as well as bringing up another
Tkinter window for more input.
The problem I have is that, even though I limited the field size/length of "entry_for_zipc" to 5,
the user can type more than 5 characters in the entry field.
How do I program it so that the user cannot type more than 5 characters in the entry field?
Thanks.
One page is a form, where the user inputs various values.
How do I limit an Entry field to a specific size?
For example, I use the following code, so that the user can put in their zip code:
# Zip code label_for_zipc = Label(main_window, text='Zip code: (First 5 digits)', fg="blue") label_for_zipc.config(font=('helvetica', 16)) canvas.create_window(0.7*hshift*fnl_x, fnl_y+vertShift, window=label_for_zipc) canvas.create_window(0.7*hshift*fnl_x, fnl_y+vertShift+30, window=entry_for_zipc)The function that includes the above lines includes many other entry fields.
There is a "Proceed" Button, which will write all the input to a file, as well as bringing up another
Tkinter window for more input.
The problem I have is that, even though I limited the field size/length of "entry_for_zipc" to 5,
the user can type more than 5 characters in the entry field.
How do I program it so that the user cannot type more than 5 characters in the entry field?
Thanks.