在为标签和按钮使用框架之前,我尝试过使用get方法。但是在使用帧之后,它总是返回一个属性错误。你知道吗
我已经尝试过这段没有框架的代码,它返回的非常好。你知道吗
root = Tk()
head = Label(root, text='LOGIN', font=('', 35), pady=10)
head.pack()
logf = Frame(root, padx=90, pady=90)
Label(logf, text='Username: ', font=('', 20), pady=5, padx=5).grid(sticky=W)
e1 = Entry(logf, bd=5, font=('Calibri', 15)).grid(row=0, column=1)
Label(logf, text='Password: ', font=('', 20), pady=5, padx=5).grid(sticky=W)
e2 = Entry(logf, bd=5, font=('Calibri', 15), show='*').grid(row=1, column=1)
Button(logf, text=' Quit ', bd=3, font=('', 15), padx=5, pady=5, command=root.quit).grid()
Button(logf, text=' Login', bd=3, font=('', 15), padx=5, pady=5, command=update).grid(row=2,column=1)
logf.pack()
username=("%s"%((e1.get())))
password=("%s"%((e2.get())))
我应该在变量中得到用户名和密码的值。你知道吗
您需要将.grid()放在下一行。你知道吗
这是:
将e2设置为.grid()的返回值,该值为nothing。这根本不创建输入字段变量/引用。这意味着您以后将无法使用e2.get()获取输入字段的值,因为e2引用不存在。你知道吗
这是:
创建e2变量/引用。这将创建一个条目,您可以使用e2.get()获取条目字段中的值。你知道吗
相关问题 更多 >
编程相关推荐