Re: [问题] Plt只显示在某个frame而不是Tk全部frame

楼主: MOONY135 (谈无欲)   2018-09-15 12:52:11
: 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出的时候你就看不到了
作者: caesar0929 (青草茶)   2018-09-15 23:15:00
谢谢 因为我第三张有另外做一些事情 换图的话可能会比较麻烦 我其实也是想只画在frame1上就好了 但我不知道关键字是什么QQ 还请大大指点迷津~~谢谢La = tk.Label(root, text="abc", image=img1, bg='gr应该是上面这行需要修改 但我不知道root要改成什么才会只画在frame1上面~~

Links booklink

Contact Us: admin [ a t ] ucptt.com