: container.pack(side="top", fill="both", expand = True)
: container.grid_rowconfigure(0, weight=1)
: container.grid_columnconfigure(0, weight=1)
: self.frames = {}
: for F in (StartPage, PageThree):
: frame = F(container, self)
: self.frames[F] = frame
: frame.grid(row=0, column=0, sticky="nsew")
: self.show_frame(StartPage)
: def show_frame(self, cont):
: frame = self.frames[cont]
: frame.tkraise()
: class StartPage(tk.Frame):
: def __init__(self, parent, root):
: super().__init__(parent)
: butt3 = tk.Button(self, text="Page3", command = lambda:
: root.show_frame(PageThree))
: butt3.place(x=100, y=400, width=150, height=80)
: butt4 = tk.Button(self, text="Plot", command = on_Plot)
: butt4.place(x=300, y=400, width=150, height=80)
: class PageThree(tk.Frame):
: def __init__(self, parent, root):
: super().__init__(parent)
: button1 = tk.Button(self, text="Home", command=lambda:
: root.show_frame(StartPage)).pack()
: root = Application()
: root.mainloop()
如果只是要做到特效的話其實做法很多
就算你是畫在root上 只要在切到frame3上面的時候 幫label換張圖也行
https://stackoverflow.com/questions/39580739/python-tkinter-label-in-frame
我通常會用的做法就是畫在frame1上面
你用的label其實應該是要放在frame1
這樣當frame3 show出的時候你就看不到了