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
56458500
Kaydet (Commit)
56458500
authored
Ara 02, 2011
tarafından
Petri Lehtinen
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Issue #13439: Merge branch 3.2
üst
c42512df
9aa20aff
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
69 deletions
+65
-69
turtle.py
Lib/turtle.py
+63
-69
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/turtle.py
Dosyayı görüntüle @
56458500
...
@@ -904,7 +904,7 @@ class Shape(object):
...
@@ -904,7 +904,7 @@ class Shape(object):
>>> poly = ((0,0),(10,-5),(0,10),(-10,-5))
>>> poly = ((0,0),(10,-5),(0,10),(-10,-5))
>>> s = Shape("compound")
>>> s = Shape("compound")
>>> s.addcomponent(poly, "red", "blue")
>>> s.addcomponent(poly, "red", "blue")
##
# .. add more components and then use register_shape()
>>>
# .. add more components and then use register_shape()
"""
"""
if
self
.
_type
!=
"compound"
:
if
self
.
_type
!=
"compound"
:
raise
TurtleGraphicsError
(
"Cannot add component to
%
s Shape"
raise
TurtleGraphicsError
(
"Cannot add component to
%
s Shape"
...
@@ -1002,7 +1002,7 @@ class TurtleScreen(TurtleScreenBase):
...
@@ -1002,7 +1002,7 @@ class TurtleScreen(TurtleScreenBase):
no backgroundimage, no eventbindings and tracing on.
no backgroundimage, no eventbindings and tracing on.
Example (for a TurtleScreen instance named screen):
Example (for a TurtleScreen instance named screen):
screen.clear()
>>>
screen.clear()
Note: this method is not available as function.
Note: this method is not available as function.
"""
"""
...
@@ -1076,8 +1076,8 @@ class TurtleScreen(TurtleScreenBase):
...
@@ -1076,8 +1076,8 @@ class TurtleScreen(TurtleScreenBase):
Example (for a TurtleScreen instance named screen):
Example (for a TurtleScreen instance named screen):
>>> screen.setworldcoordinates(-10,-0.5,50,1.5)
>>> screen.setworldcoordinates(-10,-0.5,50,1.5)
>>> for _ in range(36):
>>> for _ in range(36):
left(10)
...
left(10)
forward(0.5)
...
forward(0.5)
"""
"""
if
self
.
mode
()
!=
"world"
:
if
self
.
mode
()
!=
"world"
:
self
.
mode
(
"world"
)
self
.
mode
(
"world"
)
...
@@ -1181,7 +1181,7 @@ class TurtleScreen(TurtleScreenBase):
...
@@ -1181,7 +1181,7 @@ class TurtleScreen(TurtleScreenBase):
>>> screen.colormode()
>>> screen.colormode()
1.0
1.0
>>> screen.colormode(255)
>>> screen.colormode(255)
>>>
turtle.
pencolor(240,160,80)
>>> pencolor(240,160,80)
"""
"""
if
cmode
is
None
:
if
cmode
is
None
:
return
self
.
_colormode
return
self
.
_colormode
...
@@ -1249,9 +1249,9 @@ class TurtleScreen(TurtleScreenBase):
...
@@ -1249,9 +1249,9 @@ class TurtleScreen(TurtleScreenBase):
>>> screen.tracer(8, 25)
>>> screen.tracer(8, 25)
>>> dist = 2
>>> dist = 2
>>> for i in range(200):
>>> for i in range(200):
fd(dist)
...
fd(dist)
rt(90)
...
rt(90)
dist += 2
...
dist += 2
"""
"""
if
n
is
None
:
if
n
is
None
:
return
self
.
_tracing
return
self
.
_tracing
...
@@ -1278,7 +1278,7 @@ class TurtleScreen(TurtleScreenBase):
...
@@ -1278,7 +1278,7 @@ class TurtleScreen(TurtleScreenBase):
self
.
_delayvalue
=
int
(
delay
)
self
.
_delayvalue
=
int
(
delay
)
def
_incrementudc
(
self
):
def
_incrementudc
(
self
):
"Increment upadate counter."""
"
""
Increment upadate counter."""
if
not
TurtleScreen
.
_RUNNING
:
if
not
TurtleScreen
.
_RUNNING
:
TurtleScreen
.
_RUNNNING
=
True
TurtleScreen
.
_RUNNNING
=
True
raise
Terminator
raise
Terminator
...
@@ -1346,16 +1346,12 @@ class TurtleScreen(TurtleScreenBase):
...
@@ -1346,16 +1346,12 @@ class TurtleScreen(TurtleScreenBase):
clicked point on the canvas.
clicked point on the canvas.
num -- the number of the mouse-button, defaults to 1
num -- the number of the mouse-button, defaults to 1
Example (for a TurtleScreen instance named screen
Example (for a TurtleScreen instance named screen)
and a Turtle instance named turtle):
>>> screen.onclick(turtle.goto)
>>> screen.onclick(goto)
>>> # Subsequently clicking into the TurtleScreen will
### Subsequently clicking into the TurtleScreen will
>>> # make the turtle move to the clicked point.
### make the turtle move to the clicked point.
>>> screen.onclick(None)
>>> screen.onclick(None)
### event-binding will be removed
"""
"""
self
.
_onscreenclick
(
fun
,
btn
,
add
)
self
.
_onscreenclick
(
fun
,
btn
,
add
)
...
@@ -1369,20 +1365,18 @@ class TurtleScreen(TurtleScreenBase):
...
@@ -1369,20 +1365,18 @@ class TurtleScreen(TurtleScreenBase):
In order to be able to register key-events, TurtleScreen
In order to be able to register key-events, TurtleScreen
must have focus. (See method listen.)
must have focus. (See method listen.)
Example (for a TurtleScreen instance named screen
Example (for a TurtleScreen instance named screen):
and a Turtle instance named turtle):
>>> def f():
>>> def f():
fd(50)
... fd(50)
lt(60)
... lt(60)
...
>>> screen.onkey(f, "Up")
>>> screen.onkey(f, "Up")
>>> screen.listen()
>>> screen.listen()
### Subsequently the turtle can be moved by
Subsequently the turtle can be moved by repeatedly pressing
### repeatedly pressing the up-arrow key,
the up-arrow key, consequently drawing a hexagon
### consequently drawing a hexagon
"""
"""
if
fun
is
None
:
if
fun
is
None
:
if
key
in
self
.
_keys
:
if
key
in
self
.
_keys
:
...
@@ -1406,16 +1400,15 @@ class TurtleScreen(TurtleScreenBase):
...
@@ -1406,16 +1400,15 @@ class TurtleScreen(TurtleScreenBase):
and a Turtle instance named turtle):
and a Turtle instance named turtle):
>>> def f():
>>> def f():
fd(50)
...
fd(50)
... lt(60)
...
>>> screen.onkey(f, "Up")
>>> screen.onkey
press
(f, "Up")
>>> screen.listen()
>>> screen.listen()
### Subsequently the turtle can be moved by
Subsequently the turtle can be moved by repeatedly pressing
### repeatedly pressing the up-arrow key,
the up-arrow key, or by keeping pressed the up-arrow key.
### or by keeping pressed the up-arrow key.
consequently drawing a hexagon.
### consequently drawing a hexagon.
"""
"""
if
fun
is
None
:
if
fun
is
None
:
if
key
in
self
.
_keys
:
if
key
in
self
.
_keys
:
...
@@ -1447,12 +1440,12 @@ class TurtleScreen(TurtleScreenBase):
...
@@ -1447,12 +1440,12 @@ class TurtleScreen(TurtleScreenBase):
>>> running = True
>>> running = True
>>> def f():
>>> def f():
if running:
...
if running:
fd(50)
...
fd(50)
lt(60)
...
lt(60)
screen.ontimer(f, 250)
...
screen.ontimer(f, 250)
...
>>> f() #
##
makes the turtle marching around
>>> f() # makes the turtle marching around
>>> running = False
>>> running = False
"""
"""
self
.
_ontimer
(
fun
,
t
)
self
.
_ontimer
(
fun
,
t
)
...
@@ -1496,7 +1489,7 @@ class TurtleScreen(TurtleScreenBase):
...
@@ -1496,7 +1489,7 @@ class TurtleScreen(TurtleScreenBase):
Example (for a Turtle instance named turtle):
Example (for a Turtle instance named turtle):
>>> turtle.screensize(2000,1500)
>>> turtle.screensize(2000,1500)
### e.
g. to search for an erroneously escaped turtle ;-)
>>> # e.
g. to search for an erroneously escaped turtle ;-)
"""
"""
return
self
.
_resize
(
canvwidth
,
canvheight
,
bg
)
return
self
.
_resize
(
canvwidth
,
canvheight
,
bg
)
...
@@ -2084,7 +2077,7 @@ class TPen(object):
...
@@ -2084,7 +2077,7 @@ class TPen(object):
Example (for a Turtle instance named turtle):
Example (for a Turtle instance named turtle):
>>> turtle.pensize()
>>> turtle.pensize()
1
1
turtle.pensize(10) # from here on lines of width 10 are drawn
>>>
turtle.pensize(10) # from here on lines of width 10 are drawn
"""
"""
if
width
is
None
:
if
width
is
None
:
return
self
.
_pensize
return
self
.
_pensize
...
@@ -2559,7 +2552,7 @@ class RawTurtle(TPen, TNavigator):
...
@@ -2559,7 +2552,7 @@ class RawTurtle(TPen, TNavigator):
"""Delete the turtle's drawings and restore its default values.
"""Delete the turtle's drawings and restore its default values.
No argument.
No argument.
,
Delete the turtle's drawings from the screen, re-center the turtle
Delete the turtle's drawings from the screen, re-center the turtle
and set variables to the default values.
and set variables to the default values.
...
@@ -2606,7 +2599,7 @@ class RawTurtle(TPen, TNavigator):
...
@@ -2606,7 +2599,7 @@ class RawTurtle(TPen, TNavigator):
Example (for a Turtle instance named turtle):
Example (for a Turtle instance named turtle):
>>> while undobufferentries():
>>> while undobufferentries():
undo()
...
undo()
"""
"""
if
self
.
undobuffer
is
None
:
if
self
.
undobuffer
is
None
:
return
0
return
0
...
@@ -2682,9 +2675,9 @@ class RawTurtle(TPen, TNavigator):
...
@@ -2682,9 +2675,9 @@ class RawTurtle(TPen, TNavigator):
>>> turtle.tracer(8, 25)
>>> turtle.tracer(8, 25)
>>> dist = 2
>>> dist = 2
>>> for i in range(200):
>>> for i in range(200):
turtle.fd(dist)
...
turtle.fd(dist)
turtle.rt(90)
...
turtle.rt(90)
dist += 2
...
dist += 2
"""
"""
return
self
.
screen
.
tracer
(
flag
,
delay
)
return
self
.
screen
.
tracer
(
flag
,
delay
)
...
@@ -2882,7 +2875,6 @@ class RawTurtle(TPen, TNavigator):
...
@@ -2882,7 +2875,6 @@ class RawTurtle(TPen, TNavigator):
>>> turtle.shapesize(5,2)
>>> turtle.shapesize(5,2)
>>> turtle.tilt(45)
>>> turtle.tilt(45)
>>> turtle.tiltangle()
>>> turtle.tiltangle()
>>>
"""
"""
if
angle
is
None
:
if
angle
is
None
:
tilt
=
-
self
.
_tilt
*
(
180.0
/
math
.
pi
)
*
self
.
_angleOrient
tilt
=
-
self
.
_tilt
*
(
180.0
/
math
.
pi
)
*
self
.
_angleOrient
...
@@ -2927,7 +2919,7 @@ class RawTurtle(TPen, TNavigator):
...
@@ -2927,7 +2919,7 @@ class RawTurtle(TPen, TNavigator):
>>> turtle.shapesize(4,2)
>>> turtle.shapesize(4,2)
>>> turtle.shearfactor(-0.5)
>>> turtle.shearfactor(-0.5)
>>> turtle.shapetransform()
>>> turtle.shapetransform()
>>>
(4.0, -1.0, -0.0, 2.0)
(4.0, -1.0, -0.0, 2.0)
"""
"""
if
t11
is
t12
is
t21
is
t22
is
None
:
if
t11
is
t12
is
t21
is
t22
is
None
:
return
self
.
_shapetrafo
return
self
.
_shapetrafo
...
@@ -3125,7 +3117,7 @@ class RawTurtle(TPen, TNavigator):
...
@@ -3125,7 +3117,7 @@ class RawTurtle(TPen, TNavigator):
Example (for a Turtle instance named turtle):
Example (for a Turtle instance named turtle):
>>> for i in range(8):
>>> for i in range(8):
turtle.stamp(); turtle.fd(30)
...
turtle.stamp(); turtle.fd(30)
...
...
>>> turtle.clearstamps(2)
>>> turtle.clearstamps(2)
>>> turtle.clearstamps(-2)
>>> turtle.clearstamps(-2)
...
@@ -3301,9 +3293,9 @@ class RawTurtle(TPen, TNavigator):
...
@@ -3301,9 +3293,9 @@ class RawTurtle(TPen, TNavigator):
Example (for a Turtle instance named turtle):
Example (for a Turtle instance named turtle):
>>> turtle.begin_fill()
>>> turtle.begin_fill()
>>> if turtle.filling():
>>> if turtle.filling():
turtle.pensize(5)
...
turtle.pensize(5)
else:
...
else:
turtle.pensize(3)
...
turtle.pensize(3)
"""
"""
return
isinstance
(
self
.
_fillpath
,
list
)
return
isinstance
(
self
.
_fillpath
,
list
)
...
@@ -3533,9 +3525,9 @@ class RawTurtle(TPen, TNavigator):
...
@@ -3533,9 +3525,9 @@ class RawTurtle(TPen, TNavigator):
Example for the anonymous turtle, i. e. the procedural way:
Example for the anonymous turtle, i. e. the procedural way:
>>> def turn(x, y):
>>> def turn(x, y):
left(360)
...
left(360)
...
>>> onclick(turn) # Now clicking into the turtle will turn it.
>>> onclick(turn)
# Now clicking into the turtle will turn it.
>>> onclick(None) # event-binding will be removed
>>> onclick(None) # event-binding will be removed
"""
"""
self
.
screen
.
_onclick
(
self
.
turtle
.
_item
,
fun
,
btn
,
add
)
self
.
screen
.
_onclick
(
self
.
turtle
.
_item
,
fun
,
btn
,
add
)
...
@@ -3551,16 +3543,17 @@ class RawTurtle(TPen, TNavigator):
...
@@ -3551,16 +3543,17 @@ class RawTurtle(TPen, TNavigator):
Example (for a MyTurtle instance named joe):
Example (for a MyTurtle instance named joe):
>>> class MyTurtle(Turtle):
>>> class MyTurtle(Turtle):
def glow(self,x,y):
...
def glow(self,x,y):
self.fillcolor("red")
...
self.fillcolor("red")
def unglow(self,x,y):
...
def unglow(self,x,y):
self.fillcolor("")
...
self.fillcolor("")
...
>>> joe = MyTurtle()
>>> joe = MyTurtle()
>>> joe.onclick(joe.glow)
>>> joe.onclick(joe.glow)
>>> joe.onrelease(joe.unglow)
>>> joe.onrelease(joe.unglow)
### clicking on joe turns fillcolor red,
### unclicking turns it to transparent.
Clicking on joe turns fillcolor red, unclicking turns it to
transparent.
"""
"""
self
.
screen
.
_onrelease
(
self
.
turtle
.
_item
,
fun
,
btn
,
add
)
self
.
screen
.
_onrelease
(
self
.
turtle
.
_item
,
fun
,
btn
,
add
)
self
.
_update
()
self
.
_update
()
...
@@ -3579,9 +3572,9 @@ class RawTurtle(TPen, TNavigator):
...
@@ -3579,9 +3572,9 @@ class RawTurtle(TPen, TNavigator):
Example (for a Turtle instance named turtle):
Example (for a Turtle instance named turtle):
>>> turtle.ondrag(turtle.goto)
>>> turtle.ondrag(turtle.goto)
### Subsequently clicking and dragging a Turtle will
Subsequently clicking and dragging a Turtle will move it
### move it across the screen thereby producing handdrawing
s
across the screen thereby producing handdrawings (if pen i
s
### (if pen is
down).
down).
"""
"""
self
.
screen
.
_ondrag
(
self
.
turtle
.
_item
,
fun
,
btn
,
add
)
self
.
screen
.
_ondrag
(
self
.
turtle
.
_item
,
fun
,
btn
,
add
)
...
@@ -3629,10 +3622,11 @@ class RawTurtle(TPen, TNavigator):
...
@@ -3629,10 +3622,11 @@ class RawTurtle(TPen, TNavigator):
Example (for a Turtle instance named turtle):
Example (for a Turtle instance named turtle):
>>> for i in range(4):
>>> for i in range(4):
turtle.fd(50); turtle.lt(80)
...
turtle.fd(50); turtle.lt(80)
...
>>> for i in range(8):
>>> for i in range(8):
turtle.undo()
... turtle.undo()
...
"""
"""
if
self
.
undobuffer
is
None
:
if
self
.
undobuffer
is
None
:
return
return
...
...
Misc/NEWS
Dosyayı görüntüle @
56458500
...
@@ -399,6 +399,8 @@ Core and Builtins
...
@@ -399,6 +399,8 @@ Core and Builtins
Library
Library
-------
-------
-
Issue
#
13439
:
Fix
many
errors
in
turtle
docstrings
.
-
Issue
#
6715
:
Add
a
module
'lzma'
for
compression
using
the
LZMA
algorithm
.
-
Issue
#
6715
:
Add
a
module
'lzma'
for
compression
using
the
LZMA
algorithm
.
Thanks
to
Per
Ø
yvind
Karlsen
for
the
initial
implementation
.
Thanks
to
Per
Ø
yvind
Karlsen
for
the
initial
implementation
.
...
...
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