Python Forum
[Tkinter] How Does Entry Verification Work?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] How Does Entry Verification Work?
#1
I have the following Entry defined:
phone=tk.Entry(top,width=12,justify=tk.LEFT)
phone.grid(row=rw,column=1,pady=5,sticky=tk.W)
reg=top.register(validatePhone)
phone.config(validate='key',validatecommand=(reg,'%P'))
This is 'reg':
def validatePhone(num):
    pattern=re.compile('\d{3}-\d{3}-\d{4}')
    if (pattern.search(num)):
        print('true')
    else:
        print('false')
    return(pattern.search(num))
According to my documentation, the validate routine, 'reg', is supposed to be called every keystroke that changes the field. This does not seem to be the case. It is called only once. If I enter the first character, right or wrong, that character does not display in the field. The string 'false' is output. If I enter a 2nd character, it shows up but 'reg' apparently is never called again. Nothing seems to happen even when 'reg' returns false. Obviously I'm missing how to use entry validation and the documentation is of little help. TIA.
Reply


Messages In This Thread
How Does Entry Verification Work? - by gw1500se - Nov-13-2021, 08:43 PM
RE: How Does Entry Verification Work? - by gw1500se - Nov-17-2021, 02:16 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Transfer Toplevel window entry to root window entry with TKinter HBH 0 4,612 Jan-23-2020, 09:00 PM
Last Post: HBH
  [Tkinter] how to get the entry information using Entry.get() ? SamyPyth 2 3,628 Mar-18-2019, 05:36 PM
Last Post: woooee

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020