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.