Server IP : 51.89.169.208 / Your IP : 216.73.216.160 Web Server : Apache System : Linux ns3209505.ip-198-244-202.eu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Tue Nov 5 04:50:16 EST 2024 x86_64 User : yellowleaf ( 1019) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /proc/self/root/proc/thread-self/root/lib64/python2.7/Demo/tkinter/guido/ |
Upload File : |
# Show how to do switchable panels. from Tkinter import * class App: def __init__(self, top=None, master=None): if top is None: if master is None: top = Tk() else: top = Toplevel(master) self.top = top self.buttonframe = Frame(top) self.buttonframe.pack() self.panelframe = Frame(top, borderwidth=2, relief=GROOVE) self.panelframe.pack(expand=1, fill=BOTH) self.panels = {} self.curpanel = None def addpanel(self, name, klass): button = Button(self.buttonframe, text=name, command=lambda self=self, name=name: self.show(name)) button.pack(side=LEFT) frame = Frame(self.panelframe) instance = klass(frame) self.panels[name] = (button, frame, instance) if self.curpanel is None: self.show(name) def show(self, name): (button, frame, instance) = self.panels[name] if self.curpanel: self.curpanel.pack_forget() self.curpanel = frame frame.pack(expand=1, fill="both") class LabelPanel: def __init__(self, frame): self.label = Label(frame, text="Hello world") self.label.pack() class ButtonPanel: def __init__(self, frame): self.button = Button(frame, text="Press me") self.button.pack() def main(): app = App() app.addpanel("label", LabelPanel) app.addpanel("button", ButtonPanel) app.top.mainloop() if __name__ == '__main__': main()