Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
d7dd5149
Commit
d7dd5149
authored
Jul 15, 1998
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show how to do switchable panels.
parent
e397ca89
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
0 deletions
+54
-0
Demo/tkinter/guido/switch.py
Demo/tkinter/guido/switch.py
+54
-0
No files found.
Demo/tkinter/guido/switch.py
0 → 100644
View file @
d7dd5149
# 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
)
if
__name__
==
'__main__'
:
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment