单击后如何在 tkinter 中删除消息
how to delete a message in tkinter after click
我正在尝试从 tkinter 中删除一条消息。你能帮我吗??
Label(root,text="Password : ").place(x=X+0,y=Y+170,in_=root) #password to registor
reg_password=StringVar()
e5 = Entry(root,textvariable=reg_password).place(x=X+65,y=Y+170,in_=root)
m=Message(root,text='',fg="red").place(x=X+0,y=Y+250,in_=root)
def sign_up():
global m
regpass = "^[A-Z][\w(!@#$%^&*_+?)+]{8,}$"
if not (re.search(regpass,reg_password.get())):
m.config(text='''->Spaces and empty sets are not allowed.
\n ->First character should be a captial letter.
\n ->Password must be greater than 8 character and must contain a special character.''')
else:
pass
如果第一次输入密码错误将打印消息,第二次如果密码正确将删除消息
但是显示错误
AttributeError: 'NoneType' object has no attribute 'config'
place()
方法没有 return 值,所以语句:
m=Message(root,text='',fg="red").place(x=X+0,y=Y+250,in_=root)
将值None
赋给变量m
。
将它分成两个语句:
m = Message(root, text='', fg="red")
m.place(x=X+0, y=Y+250, in_=root)
我正在尝试从 tkinter 中删除一条消息。你能帮我吗??
Label(root,text="Password : ").place(x=X+0,y=Y+170,in_=root) #password to registor
reg_password=StringVar()
e5 = Entry(root,textvariable=reg_password).place(x=X+65,y=Y+170,in_=root)
m=Message(root,text='',fg="red").place(x=X+0,y=Y+250,in_=root)
def sign_up():
global m
regpass = "^[A-Z][\w(!@#$%^&*_+?)+]{8,}$"
if not (re.search(regpass,reg_password.get())):
m.config(text='''->Spaces and empty sets are not allowed.
\n ->First character should be a captial letter.
\n ->Password must be greater than 8 character and must contain a special character.''')
else:
pass
如果第一次输入密码错误将打印消息,第二次如果密码正确将删除消息
但是显示错误
AttributeError: 'NoneType' object has no attribute 'config'
place()
方法没有 return 值,所以语句:
m=Message(root,text='',fg="red").place(x=X+0,y=Y+250,in_=root)
将值None
赋给变量m
。
将它分成两个语句:
m = Message(root, text='', fg="red")
m.place(x=X+0, y=Y+250, in_=root)