-1
這是我的代碼中,我試圖鏈接
兩頁from Tkinter import *
class Example(Frame):
def __init__(self , parent, controller):
Frame.__init__(self, parent)
self.controller=controller
self.parent = parent
self.parent.title("f2")
self.parent.configure(background="royalblue4")
self.pack(fill=BOTH, expand=1)
w = 800
h = 500
sw = self.parent.winfo_screenwidth()
sh = self.parent.winfo_screenheight()
x = (sw - w)/2
y = (sh - h)/2
self.parent.geometry('%dx%d+%d+%d' % (w, h, x, y))
self.logbtn1 = Button(self,text="SIGN UP",font=("Copperplate Gothic Bold",16),bg=("dark green"),activebackground=("green"),command=lambda: controller.show_frame("D:\java prgms\minor\signup"))
self.logbtn1.place(x=325,y=175)
self.logbtn2 = Button(self, text="LOGIN",font=("Copperplate Gothic Bold",16),bg=("cyan"),activebackground=("yellow"),command=lambda: controller.show_frame("D:\java prgms\minor\log1"))
self.logbtn2.place(x=335,y=220)
self.pack()
def main():
root = Tk()
ex = Example(root,Frame)
root.mainloop()
if __name__ == '__main__':
main()
但是在這裏我得到這個錯誤信息:「AttributeError錯誤:類框架有沒有屬性‘show_frame’」
AttributeError: class Frame has no attribute 'show_frame'
how to remove this error
我試過你的代碼它工作 –