Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
c6a1c02c
Kaydet (Commit)
c6a1c02c
authored
Eyl 03, 2014
tarafından
Terry Jan Reedy
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #21933: Users can now change the font size for example code.
Original patch by Lita Cho.
üst
282124b8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
22 deletions
+71
-22
__main__.py
Lib/turtledemo/__main__.py
+71
-22
No files found.
Lib/turtledemo/__main__.py
Dosyayı görüntüle @
c6a1c02c
...
@@ -17,14 +17,17 @@
...
@@ -17,14 +17,17 @@
The (syntax coloured) source code appears in the left
The (syntax coloured) source code appears in the left
source code window. IT CANNOT BE EDITED, but ONLY VIEWED!
source code window. IT CANNOT BE EDITED, but ONLY VIEWED!
- Press START button to start the demo.
The demo viewer windows can be resized. The divider between text
- Stop execution by pressing the STOP button.
and canvas can be moved by grabbing it with the mouse. The text font
- Clear screen by pressing the CLEAR button
.
size can be changed from the menu and with Control/Command- '-'/'+'
.
- Restart by pressing the START button again
.
It can also be changed on most systems with Control-mousewheel
.
SPECIAL demos are those which run EVENTDRIVEN.
Press START button to start the demo.
(For example clock.py - or oldTurtleDemo.py which
Stop execution by pressing the STOP button.
in the end expects a mouse click.):
Clear screen by pressing the CLEAR button.
Restart by pressing the START button again.
SPECIAL demos, such as clock.py are those which run EVENTDRIVEN.
Press START button to start the demo.
Press START button to start the demo.
...
@@ -87,7 +90,7 @@ import os
...
@@ -87,7 +90,7 @@ import os
from
tkinter
import
*
from
tkinter
import
*
from
idlelib.Percolator
import
Percolator
from
idlelib.Percolator
import
Percolator
from
idlelib.ColorDelegator
import
ColorDelegator
from
idlelib.ColorDelegator
import
ColorDelegator
from
idlelib.textView
import
view_text
# TextViewer
from
idlelib.textView
import
view_text
from
importlib
import
reload
from
importlib
import
reload
from
turtledemo
import
__doc__
as
about_turtledemo
from
turtledemo
import
__doc__
as
about_turtledemo
...
@@ -95,6 +98,7 @@ import turtle
...
@@ -95,6 +98,7 @@ import turtle
import
time
import
time
demo_dir
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
demo_dir
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
darwin
=
sys
.
platform
==
'darwin'
STARTUP
=
1
STARTUP
=
1
READY
=
2
READY
=
2
...
@@ -104,7 +108,11 @@ EVENTDRIVEN = 5
...
@@ -104,7 +108,11 @@ EVENTDRIVEN = 5
menufont
=
(
"Arial"
,
12
,
NORMAL
)
menufont
=
(
"Arial"
,
12
,
NORMAL
)
btnfont
=
(
"Arial"
,
12
,
'bold'
)
btnfont
=
(
"Arial"
,
12
,
'bold'
)
txtfont
=
(
'Lucida Console'
,
8
,
'normal'
)
txtfont
=
[
'Lucida Console'
,
10
,
'normal'
]
MINIMUM_FONT_SIZE
=
6
MAXIMUM_FONT_SIZE
=
100
font_sizes
=
[
8
,
9
,
10
,
11
,
12
,
14
,
18
,
20
,
22
,
24
,
30
]
def
getExampleEntries
():
def
getExampleEntries
():
return
[
entry
[:
-
3
]
for
entry
in
os
.
listdir
(
demo_dir
)
if
return
[
entry
[:
-
3
]
for
entry
in
os
.
listdir
(
demo_dir
)
if
...
@@ -123,7 +131,7 @@ class DemoWindow(object):
...
@@ -123,7 +131,7 @@ class DemoWindow(object):
root
.
title
(
'Python turtle-graphics examples'
)
root
.
title
(
'Python turtle-graphics examples'
)
root
.
wm_protocol
(
"WM_DELETE_WINDOW"
,
self
.
_destroy
)
root
.
wm_protocol
(
"WM_DELETE_WINDOW"
,
self
.
_destroy
)
if
sys
.
platform
==
'darwin'
:
if
darwin
:
import
subprocess
import
subprocess
# Make sure we are the currently activated OS X application
# Make sure we are the currently activated OS X application
# so that our menu bar appears.
# so that our menu bar appears.
...
@@ -136,8 +144,7 @@ class DemoWindow(object):
...
@@ -136,8 +144,7 @@ class DemoWindow(object):
'-e'
,
'end tell'
,
'-e'
,
'end tell'
,
],
],
stderr
=
subprocess
.
DEVNULL
,
stderr
=
subprocess
.
DEVNULL
,
stdout
=
subprocess
.
DEVNULL
,
stdout
=
subprocess
.
DEVNULL
,)
)
root
.
grid_rowconfigure
(
0
,
weight
=
1
)
root
.
grid_rowconfigure
(
0
,
weight
=
1
)
root
.
grid_columnconfigure
(
0
,
weight
=
1
)
root
.
grid_columnconfigure
(
0
,
weight
=
1
)
...
@@ -147,9 +154,11 @@ class DemoWindow(object):
...
@@ -147,9 +154,11 @@ class DemoWindow(object):
self
.
mBar
=
Menu
(
root
,
relief
=
RAISED
,
borderwidth
=
2
)
self
.
mBar
=
Menu
(
root
,
relief
=
RAISED
,
borderwidth
=
2
)
self
.
mBar
.
add_cascade
(
menu
=
self
.
makeLoadDemoMenu
(
self
.
mBar
),
self
.
mBar
.
add_cascade
(
menu
=
self
.
makeLoadDemoMenu
(
self
.
mBar
),
label
=
'Examples'
,
underline
=
0
,
font
=
menufont
)
label
=
'Examples'
,
underline
=
0
)
self
.
mBar
.
add_cascade
(
menu
=
self
.
makeFontMenu
(
self
.
mBar
),
label
=
'Fontsize'
,
underline
=
0
)
self
.
mBar
.
add_cascade
(
menu
=
self
.
makeHelpMenu
(
self
.
mBar
),
self
.
mBar
.
add_cascade
(
menu
=
self
.
makeHelpMenu
(
self
.
mBar
),
label
=
'Help'
,
underline
=
0
,
font
=
menufont
)
label
=
'Help'
,
underline
=
0
)
root
[
'menu'
]
=
self
.
mBar
root
[
'menu'
]
=
self
.
mBar
pane
=
PanedWindow
(
orient
=
HORIZONTAL
,
sashwidth
=
5
,
pane
=
PanedWindow
(
orient
=
HORIZONTAL
,
sashwidth
=
5
,
...
@@ -203,7 +212,7 @@ class DemoWindow(object):
...
@@ -203,7 +212,7 @@ class DemoWindow(object):
hbar
[
'command'
]
=
text
.
xview
hbar
[
'command'
]
=
text
.
xview
hbar
.
pack
(
side
=
BOTTOM
,
fill
=
X
)
hbar
.
pack
(
side
=
BOTTOM
,
fill
=
X
)
text
[
'font'
]
=
t
xtfont
text
[
'font'
]
=
t
uple
(
txtfont
)
text
[
'yscrollcommand'
]
=
vbar
.
set
text
[
'yscrollcommand'
]
=
vbar
.
set
text
[
'xscrollcommand'
]
=
hbar
.
set
text
[
'xscrollcommand'
]
=
hbar
.
set
text
.
pack
(
side
=
LEFT
,
fill
=
BOTH
,
expand
=
1
)
text
.
pack
(
side
=
LEFT
,
fill
=
BOTH
,
expand
=
1
)
...
@@ -216,7 +225,7 @@ class DemoWindow(object):
...
@@ -216,7 +225,7 @@ class DemoWindow(object):
turtle
.
_Screen
.
_canvas
=
self
.
_canvas
=
canvas
=
turtle
.
ScrolledCanvas
(
turtle
.
_Screen
.
_canvas
=
self
.
_canvas
=
canvas
=
turtle
.
ScrolledCanvas
(
root
,
800
,
600
,
self
.
canvwidth
,
self
.
canvheight
)
root
,
800
,
600
,
self
.
canvwidth
,
self
.
canvheight
)
canvas
.
adjustScrolls
()
canvas
.
adjustScrolls
()
canvas
.
_rootwindow
.
bind
(
'<Configure>'
,
self
.
onResize
)
self
.
makeBindings
(
canvas
.
_rootwindow
)
canvas
.
_canvas
[
'borderwidth'
]
=
0
canvas
.
_canvas
[
'borderwidth'
]
=
0
self
.
screen
=
_s_
=
turtle
.
Screen
()
self
.
screen
=
_s_
=
turtle
.
Screen
()
...
@@ -225,6 +234,35 @@ class DemoWindow(object):
...
@@ -225,6 +234,35 @@ class DemoWindow(object):
turtle
.
RawTurtle
.
screens
=
[
_s_
]
turtle
.
RawTurtle
.
screens
=
[
_s_
]
return
canvas
return
canvas
def
makeBindings
(
self
,
widget
):
widget
.
bind
(
'<Configure>'
,
self
.
onResize
)
shortcut
=
'Command'
if
darwin
else
'Control'
widget
.
bind_all
(
'<
%
s-minus>'
%
shortcut
,
self
.
decrease_size
)
widget
.
bind_all
(
'<
%
s-underscore>'
%
shortcut
,
self
.
decrease_size
)
widget
.
bind_all
(
'<
%
s-equal>'
%
shortcut
,
self
.
increase_size
)
widget
.
bind_all
(
'<
%
s-plus>'
%
shortcut
,
self
.
increase_size
)
widget
.
bind_all
(
'<Control-MouseWheel>'
,
self
.
update_mousewheel
)
widget
.
bind
(
'<Control-Button-4>'
,
self
.
increase_size
)
widget
.
bind
(
'<Control-Button-5>'
,
self
.
decrease_size
)
def
set_txtsize
(
self
,
size
):
txtfont
[
1
]
=
size
self
.
text
[
'font'
]
=
tuple
(
txtfont
)
self
.
output_lbl
[
'text'
]
=
'Font size
%
d'
%
size
def
decrease_size
(
self
,
dummy
=
None
):
self
.
set_txtsize
(
max
(
txtfont
[
1
]
-
1
,
MINIMUM_FONT_SIZE
))
def
increase_size
(
self
,
dummy
=
None
):
self
.
set_txtsize
(
min
(
txtfont
[
1
]
+
1
,
MAXIMUM_FONT_SIZE
))
def
update_mousewheel
(
self
,
event
):
# For wheel up, event.delte = 120 on Windows, -1 on darwin.
# X-11 sends Control-Button-4 event instead.
(
self
.
decrease_size
()
if
(
event
.
delta
<
0
and
not
darwin
)
else
self
.
increase_size
())
def
configGUI
(
self
,
start
,
stop
,
clear
,
txt
=
""
,
color
=
"blue"
):
def
configGUI
(
self
,
start
,
stop
,
clear
,
txt
=
""
,
color
=
"blue"
):
self
.
start_btn
.
config
(
state
=
start
,
self
.
start_btn
.
config
(
state
=
start
,
bg
=
"#d00"
if
start
==
NORMAL
else
"#fca"
)
bg
=
"#d00"
if
start
==
NORMAL
else
"#fca"
)
...
@@ -238,13 +276,25 @@ class DemoWindow(object):
...
@@ -238,13 +276,25 @@ class DemoWindow(object):
menu
=
Menu
(
master
)
menu
=
Menu
(
master
)
for
entry
in
getExampleEntries
():
for
entry
in
getExampleEntries
():
def
loadexample
(
x
):
def
load
(
entry
=
entry
):
def
emit
():
self
.
loadfile
(
entry
)
self
.
loadfile
(
x
)
return
emit
menu
.
add_command
(
label
=
entry
,
underline
=
0
,
menu
.
add_command
(
label
=
entry
,
underline
=
0
,
font
=
menufont
,
command
=
loadexample
(
entry
))
font
=
menufont
,
command
=
load
)
return
menu
def
makeFontMenu
(
self
,
master
):
menu
=
Menu
(
master
)
menu
.
add_command
(
label
=
"Decrease (C-'-')"
,
command
=
self
.
decrease_size
,
font
=
menufont
)
menu
.
add_command
(
label
=
"Increase (C-'+')"
,
command
=
self
.
increase_size
,
font
=
menufont
)
menu
.
add_separator
()
for
size
in
font_sizes
:
def
resize
(
size
=
size
):
self
.
set_txtsize
(
size
)
menu
.
add_command
(
label
=
str
(
size
),
underline
=
0
,
font
=
menufont
,
command
=
resize
)
return
menu
return
menu
def
makeHelpMenu
(
self
,
master
):
def
makeHelpMenu
(
self
,
master
):
...
@@ -254,7 +304,6 @@ class DemoWindow(object):
...
@@ -254,7 +304,6 @@ class DemoWindow(object):
def
show
(
help_label
=
help_label
,
help_file
=
help_file
):
def
show
(
help_label
=
help_label
,
help_file
=
help_file
):
view_text
(
self
.
root
,
help_label
,
help_file
)
view_text
(
self
.
root
,
help_label
,
help_file
)
menu
.
add_command
(
label
=
help_label
,
font
=
menufont
,
command
=
show
)
menu
.
add_command
(
label
=
help_label
,
font
=
menufont
,
command
=
show
)
return
menu
return
menu
def
refreshCanvas
(
self
):
def
refreshCanvas
(
self
):
...
...
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