在我正在开发的修订版应用程序中,我正在寻找用户答案(他们希望关注的修订版区域),然后加载他们需要的特定区域。
这需要输入小部件吗?
这是我到目前为止的代码:
instruction = tkinter.Label(roots, text= "'What would you like to revise?'\n")
instruction.grid(row=0, column=0,sticky=W)
if int(answer) != int(entryWidget.get().strip()):
tkMessageBox.showinfo("Answer", "INCORRECT!")
else:
tkMessageBox.showinfo("Answer", "CORRECT!")
我为缺乏代码而道歉,但我不确定如何在此之后开发它而不知道如何从这一点加载我的备用代码部分
第2部分:
def Signup():
global pwordE
global nameE
global roots
roots = tkinter.Tk()
roots.title("Computer Science Revision")
roots.geometry("1000x1000")
roots.wm_iconbitmap('favicon.ico')
roots.configure(background="#a1dbcd")
photo= tkinter.PhotoImage(roots,file="ryu.gif")
A = tkinter.Label(roots,image=photo)
A.pack()
roots = tkinter.Tk()
roots.title('Signup')
instruction = tkinter.Label(roots, text= 'Please enter new Credentials\n')
instruction.grid(row=0, column=0,sticky=W)
nameL = tkinter.Label(roots, text='New Username: ')
pwordL = tkinter.Label(roots, text='New Password: ')
nameL.grid(row=1, column=0, sticky=W)
pwordL.grid(row=2, column=0, sticky=W)
nameE= tkinter.Entry(roots)
pwordE = tkinter.Entry(roots, show='*')
nameE.grid(row=1, column=1)
pwordE.grid(row=2, column=1)
signupButton = Button(roots, text='Signup', command=FSSignup)
signupButton.grid(columnspan=2, sticky=W)
roots.mainloop()
roots.title("Computer Science Revision")
roots.geometry("1000x1000")
roots.wm_iconbitmap('favicon.ico')
roots.configure(background="#a1dbcd")
photo= tkinter.PhotoImage(roots,file="ryu.gif")
A = tkinter.Label(roots,image=photo)
A.pack()
此部分不会加载其余的登录信息,我该如何解决?
答案 0 :(得分:2)
我希望你问这样的事情。
import tkinter as tk
root = tk.Tk()
root.geometry("500x500+100+100")
def raise_frame(frame):
frame.tkraise()
f1 = tk.Frame(root)
f2 = tk.Frame(root)
f3 = tk.Frame(root)
f4 = tk.Frame(root)
for frame in (f1,f2,f3,f4):
frame.grid(row=0, column=0, sticky='news')
#Frame1
button1 = tk.Button(f1, text='English', command=lambda:raise_frame(f2)).pack()
button2 = tk.Button(f1, text='Maths', command=lambda:raise_frame(f3)).pack()
button3 = tk.Button(f1, text='Science', command=lambda:raise_frame(f4)).pack()
#Frame2
tk.Label(f2, text="English Revision").pack()
tk.Button(f2, text="HOME", command=lambda:raise_frame(f1)).pack()
#Frame3
tk.Label(f3, text="Maths Revision").pack()
tk.Button(f3, text="HOME", command=lambda:raise_frame(f1)).pack()
#Frame4
tk.Label(f4, text="Science Revision").pack()
tk.Button(f4, text="HOME", command=lambda:raise_frame(f1)).pack()
raise_frame(f1)
root.mainloop()