You could test the length of the input and throw an error and remind that only 5 characters are allowed.
Quick example
Quick example
import tkinter as tk from tkinter import messagebox def callback(field, arg): arg = arg.get() if len(arg) != 5: messagebox.showerror('Error', 'field must contain 5 characters') field.delete(0, tk.END) else: messagebox.showinfo('Correct', 'This field has 5 characters') root = tk.Tk() var = tk.StringVar() contain = tk.LabelFrame(root, text='Some label text') contain.pack(fill='both', expand=True) field = tk.Entry(contain, textvariable=var, bd=2) field.pack(fill='x', expand=True) btn = tk.Button(contain, text='Submit', command=lambda: callback(field, var)) btn.pack(side='left', fill='x', pady=5) root.mainloop()
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags