思路:
登录系统,当我点击button是会弹出一个信息“登录中请稍后”并且同时运行登录校验的方法。
但是我目前遇到的问题是,它总是在登录校验结束之后才弹出出提示信息
下面是部分相关代码
state = False
def createWidegt(self):
"""创建登录界面的组件"""
# 创建用户名框
self.label01 = Label(self, text='用户名').pack()
# StringVar变量绑定到指定的组件
# StringVar变量的值发生变化,组件内容也变化
# 组件内容发生变化,StringVar变量的值也发生变化
user = StringVar()
self.entry01 = Entry(self, textvariable=user)
self.entry01.pack()
# user.set('admin') # 设置默认为"admin"
# print(v1.get())
# print(self.entry01.get())
# 创建密码框
self.label02 = Label(self, text='密码').pack()
password = StringVar()
self.entry02 = Entry(self, textvariable=password)
self.entry02.pack()
self.label00 = Label(self, text='')
self.label00.pack()
self.btn01 = Button(self, text='登录', command=self.login).pack()
# def test(self):
# print(111)
# self.label00 = Label(self, text='登录中请稍后').pack()
# print(222)
# self.login()
def login(self):
global state
username = self.entry01.get()
password = self.entry02.get()
if state == False:
self.label00['text'] = '登录中请稍后'
state = True
if state == True:
# 登录校验