我正在尝试制作一个程序,一旦勾选了勾选框,电子邮件的字段就会出现,但当取消勾选时,当您按下更新时,字段就会消失
但我不断得到:
emailLabel.destroy()
UnboundLocalError: local variable 'emailLabel' referenced before assignment
有什么建议吗?下面是我的代码:
#so when you tick the box, the value is 1 so this checks for that and sets a equal to 1
#if the box isnt ticked then it checks a and if it is equal to 1 then it
#deletes the fields for the email and code.
#PLEASE HELP. Error is in this bit
def update(var1):
global signupas
global a
print(a)
checklist = var1.get()
print(checklist)
if checklist == 1:
a= 1
if a == checklist:
# // but it's referenced here:
global email
emailLabel = Label(signupas, text="Email")
emailLabel.grid(row=3, column=0)
email = StringVar()
emailEntry = Entry(signupas, textvariable=email)
emailEntry.grid(row=3, column=1)
codeLabel = Label(signupas, text="code")
codeLabel.grid(row=4, column=0)
code = StringVar()
codeEntry = Entry(signupas, textvariable=email)
codeEntry.grid(row=4, column=1)
#its on about this bit:
if a == 1 and checklist == 0:
emailLabel.destroy()
codeLabel.destroy()
signupas.mainloop()
#//this gets the information for the update as it checks for the check box
#//error isn't here but above so don't worry about signup().
def signup():
global signupas
signupas = tk.Toplevel()
signupas.geometry('300x200')
tkWindow.title("database program")
usernameLabel = Label(signupas, text="Username").grid(row=0, column=0)
username = StringVar()
usernameEntry = Entry(signupas, textvariable=username).grid(row=0, column=1)
passwordLabel = Label(signupas,text="Password").grid(row=1, column=0)
password = StringVar()
passwordEntry = Entry(signupas, textvariable=password, show='*').grid(row=1, column=1)
var1 = IntVar()
Checkbutton(signupas, text="2step verification", variable=var1).grid(row=2)
SignUp = partial(checkuser_email, username, password, var1)
updates = partial(update, var1)
updateButton = Button(signupas, text="Update", command=updates).grid(row=5, column=2)
signupButton = Button(signupas, text="SignUp", command=SignUp).grid(row=5, column=1)
signupas.mainloop()
提前感谢:)
目前没有回答
相关问题 更多 >
编程相关推荐