diff options
author | Georg Brandl <georg@python.org> | 2010-12-30 21:33:07 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2010-12-30 21:33:07 (GMT) |
commit | 7fafbc95c0c963438197c9a43fe893c4ea6fe759 (patch) | |
tree | 5c9ceda4bdc5260236a230554b9ed56b8c0cdbd3 /Demo/tkinter/guido/switch.py | |
parent | 6f17e2df29a865a29447531e89fb22be710e382d (diff) | |
download | cpython-7fafbc95c0c963438197c9a43fe893c4ea6fe759.zip cpython-7fafbc95c0c963438197c9a43fe893c4ea6fe759.tar.gz cpython-7fafbc95c0c963438197c9a43fe893c4ea6fe759.tar.bz2 |
More cleanup: Move some demos into a dedicated Tools/demo dir, move 2to3 demo to Tools, and remove all the other Demo content.
Diffstat (limited to 'Demo/tkinter/guido/switch.py')
-rw-r--r-- | Demo/tkinter/guido/switch.py | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/Demo/tkinter/guido/switch.py b/Demo/tkinter/guido/switch.py deleted file mode 100644 index 3f43925..0000000 --- a/Demo/tkinter/guido/switch.py +++ /dev/null @@ -1,55 +0,0 @@ -# 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() |