# 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()
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
AttrDialog.py | File | 14 KB | 0644 |
|
AttrDialog.pyc | File | 18.33 KB | 0644 |
|
AttrDialog.pyo | File | 18.33 KB | 0644 |
|
ManPage.py | File | 6.7 KB | 0644 |
|
ManPage.pyc | File | 6.27 KB | 0644 |
|
ManPage.pyo | File | 6.27 KB | 0644 |
|
MimeViewer.py | File | 4.39 KB | 0755 |
|
MimeViewer.pyc | File | 4.83 KB | 0644 |
|
MimeViewer.pyo | File | 4.83 KB | 0644 |
|
ShellWindow.py | File | 4.07 KB | 0644 |
|
ShellWindow.pyc | File | 5.47 KB | 0644 |
|
ShellWindow.pyo | File | 5.47 KB | 0644 |
|
brownian.py | File | 1.07 KB | 0644 |
|
brownian.pyc | File | 1.59 KB | 0644 |
|
brownian.pyo | File | 1.59 KB | 0644 |
|
brownian2.py | File | 1.35 KB | 0644 |
|
brownian2.pyc | File | 1.74 KB | 0644 |
|
brownian2.pyo | File | 1.74 KB | 0644 |
|
canvasevents.py | File | 6.45 KB | 0755 |
|
canvasevents.pyc | File | 10.46 KB | 0644 |
|
canvasevents.pyo | File | 10.46 KB | 0644 |
|
dialog.py | File | 3.13 KB | 0755 |
|
dialog.pyc | File | 3.11 KB | 0644 |
|
dialog.pyo | File | 3.11 KB | 0644 |
|
electrons.py | File | 2.27 KB | 0755 |
|
electrons.pyc | File | 2.33 KB | 0644 |
|
electrons.pyo | File | 2.33 KB | 0644 |
|
hanoi.py | File | 4.54 KB | 0644 |
|
hanoi.pyc | File | 3.82 KB | 0644 |
|
hanoi.pyo | File | 3.82 KB | 0644 |
|
hello.py | File | 331 B | 0644 |
|
hello.pyc | File | 701 B | 0644 |
|
hello.pyo | File | 701 B | 0644 |
|
imagedraw.py | File | 509 B | 0644 |
|
imagedraw.pyc | File | 1.13 KB | 0644 |
|
imagedraw.pyo | File | 1.13 KB | 0644 |
|
imageview.py | File | 205 B | 0644 |
|
imageview.pyc | File | 570 B | 0644 |
|
imageview.pyo | File | 570 B | 0644 |
|
kill.py | File | 3.79 KB | 0755 |
|
kill.pyc | File | 4.81 KB | 0644 |
|
kill.pyo | File | 4.81 KB | 0644 |
|
listtree.py | File | 991 B | 0644 |
|
listtree.pyc | File | 1.5 KB | 0644 |
|
listtree.pyo | File | 1.5 KB | 0644 |
|
mbox.py | File | 7.3 KB | 0755 |
|
mbox.pyc | File | 8.17 KB | 0644 |
|
mbox.pyo | File | 8.17 KB | 0644 |
|
newmenubardemo.py | File | 1.2 KB | 0755 |
|
newmenubardemo.pyc | File | 1.59 KB | 0644 |
|
newmenubardemo.pyo | File | 1.59 KB | 0644 |
|
optionmenu.py | File | 441 B | 0644 |
|
optionmenu.pyc | File | 594 B | 0644 |
|
optionmenu.pyo | File | 594 B | 0644 |
|
paint.py | File | 1.85 KB | 0644 |
|
paint.pyc | File | 2.19 KB | 0644 |
|
paint.pyo | File | 2.19 KB | 0644 |
|
rmt.py | File | 4.39 KB | 0755 |
|
rmt.pyc | File | 4.93 KB | 0644 |
|
rmt.pyo | File | 4.93 KB | 0644 |
|
solitaire.py | File | 17.37 KB | 0755 |
|
solitaire.pyc | File | 20.41 KB | 0644 |
|
solitaire.pyo | File | 20.41 KB | 0644 |
|
sortvisu.py | File | 18.89 KB | 0755 |
|
sortvisu.pyc | File | 23.18 KB | 0644 |
|
sortvisu.pyo | File | 23.18 KB | 0644 |
|
ss1.py | File | 25.57 KB | 0644 |
|
ss1.pyc | File | 31.67 KB | 0644 |
|
ss1.pyo | File | 31.07 KB | 0644 |
|
svkill.py | File | 4.75 KB | 0755 |
|
svkill.pyc | File | 5.8 KB | 0644 |
|
svkill.pyo | File | 5.8 KB | 0644 |
|
switch.py | File | 1.52 KB | 0644 |
|
switch.pyc | File | 2.85 KB | 0644 |
|
switch.pyo | File | 2.85 KB | 0644 |
|
tkman.py | File | 8.79 KB | 0755 |
|
tkman.pyc | File | 8.88 KB | 0644 |
|
tkman.pyo | File | 8.88 KB | 0644 |
|
wish.py | File | 623 B | 0644 |
|
wish.pyc | File | 737 B | 0644 |
|
wish.pyo | File | 737 B | 0644 |
|