Created
March 2, 2018 02:52
-
-
Save PandyYang/d779a806e8a28cdbc365ae8ac9feaffa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tkinter import * | |
master = Tk() | |
def test1(): | |
if e1.get() == "pandy": | |
print("验证通过!") | |
return True | |
else: | |
print("验证失败!") | |
e1.delete(0,END) | |
return False | |
def test2(): | |
print("我被调用了...") | |
return True | |
v = StringVar() | |
e1 = Entry(master,textvariable=v,validate = 'focusout',validatecommand=test1,invalidcommand = test2) | |
e2 = Entry(master) | |
e1.pack(padx = 10,pady = 10) | |
e2.pack(padx = 10,pady = 10) | |
mainloop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment