gpt4 book ai didi

python - 如何在点击后删除 tkinter 中的消息

转载 作者:太空宇宙 更新时间:2023-11-03 20:36:16 25 4
gpt4 key购买 nike

我正在尝试从 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() 方法不返回值,因此语句:

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)

关于python - 如何在点击后删除 tkinter 中的消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57149587/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com