首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >点击后如何在tkinter中删除消息

点击后如何在tkinter中删除消息
EN

Stack Overflow用户
提问于 2019-07-22 23:48:41
回答 1查看 25关注 0票数 1

我正在尝试删除tkinter中的一条消息。你能帮我弄一下吗?

代码语言:javascript
复制
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

如果第一次输入的密码错误,将打印消息;第二次,如果密码正确,消息将被删除

但是它显示了错误

代码语言:javascript
复制
AttributeError: 'NoneType' object has no attribute 'config'
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-07-22 23:58:25

place()方法不返回值,因此语句:

代码语言:javascript
复制
m=Message(root,text='',fg="red").place(x=X+0,y=Y+250,in_=root) 

将值None赋给变量m

将其拆分成两个语句:

代码语言:javascript
复制
m = Message(root, text='', fg="red")
m.place(x=X+0, y=Y+250, in_=root) 
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57149587

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档