1
# Show how to do switchable panels.
7
def __init__(self, top=None, master=None):
12
top = Toplevel(master)
14
self.buttonframe = Frame(top)
15
self.buttonframe.pack()
16
self.panelframe = Frame(top, borderwidth=2, relief=GROOVE)
17
self.panelframe.pack(expand=1, fill=BOTH)
21
def addpanel(self, name, klass):
22
button = Button(self.buttonframe, text=name,
23
command=lambda self=self, name=name: self.show(name))
24
button.pack(side=LEFT)
25
frame = Frame(self.panelframe)
26
instance = klass(frame)
27
self.panels[name] = (button, frame, instance)
28
if self.curpanel is None:
32
(button, frame, instance) = self.panels[name]
34
self.curpanel.pack_forget()
36
frame.pack(expand=1, fill="both")
39
def __init__(self, frame):
40
self.label = Label(frame, text="Hello world")
44
def __init__(self, frame):
45
self.button = Button(frame, text="Press me")
50
app.addpanel("label", LabelPanel)
51
app.addpanel("button", ButtonPanel)
54
if __name__ == '__main__':