06.02.2012

????, ???? ??????? ????? tk

Original on http://docs.python.org/release/3.0.1/library/turtle.html

?

????????????

???? ????????? ?? ?????? ???????? ????????????? ???????????? ? ??????????. ??? ?????? ?? ???? ???????? ???????????? ????? ?????? ??????? wally-Feurzig ?? ??????? Papert 1966 ?.

??????????? ?? robotic ??? ????? (0, 0) – ?? xy ??????????????. ??? ?????? turtle.forward (15), ?? ??? ???????? ? (on-screen!) 15 ?????? ??????????? ? ???????, ?? ?????? ???, ?????? ?? ??? ???????? ?. ??? ?????? turtle.left (25), ?? ?? ??????????-? ???? 25 ??????? ???????? ???????????.

??? ??????????? ?????? ??? ?? ???????? ??????????, ?????? ?????????? ?? ????????? ??????????? ????? ? ???????.

The ???? ?????? ? ?????????? reimplementation ? ????? ??????? ??????? ????? python ????? ???????? ???????? ?????? ???????? python ????? 2.5.

??? ??????? ? ???????? ??????? ??? ???? ??????? ?? ????? (?????) 100% ?????????? ?. ?? ????????? ? ?????? ?????? ??????????????? ??????? ????????? ??????????? ? ?????????? ????? ?????????? ????? ?? ???????? interactively ???????????? ??????? ?????? idle ?????? ??? - ? ???.

The ???? ??????? ????????? ???? ????????? primitives, ????? object-oriented ?? ??????????? ??????? ???????: ???? ?? ??? ??????????? ? Tkinter ????? ??????? ????? ?????????, ??? ????? ???? ????????? ????????? ? python ????? tk ????????????:

The object-oriented ???????? ??????????? ? ??????????? ?????+ ????? ???????????:

  1. The TurtleScreen ????? ????????? ???????? ????????????, ?????? ???? ????????????? ????? ? turtles. ??? ??????? ????? ???? Tkinter.???? ??? ScrolledCanvas ????? ???????: ??? ???? ? ??????????, ??? ???? ???????????? ? ????? ???, ??? ???????

    ??????????? ?????? () ???????????? ? singleton ?????? ? TurtleScreen ???????: ??? ????????? ???? ? ??????????, ??? ???? ???????????? ? ????? ?????? standalone ????? ???????. ????? singleton ??????, ?????????? ?? ????? ???????? ??:

    ????? ????????? TurtleScreen ????? ?????? ???????? ?????????? ?????, ???? ?? ??????? ?, ???????, ????? ???? ????? `??????? ??????????.

  2. RawTurtle (alias ?????? RawPen) ????????? ???? ??????????, ????? ???????????? ????? TurtleScreen. ??? ??????? ????? ???? ????, ScrolledCanvas ??? TurtleScreen ????? ???????, ??????? RawTurtle ??????????, ?? ????? ???? ? ??????:

    ???????? RawTurtle ? ??????? ???? (alias ??????: ????????????), ??? ?? - ??? ? «??? ? ?????? – ?? ??????, ??? ???????????? ?????????, ??? ??, ????? ????.

    ????? ????????? RawTurtle ????? ??? ???? ????? ?????????? ??????????????? ?, ??????? ???? ????? `??????? ??????????.

??? ????????????? ?????????? ?????????? ?????????????, ????? ???? ????????? ?????? ?????? ?? ????. ????? ????? ????? ?????????, ???????? ?? ???????????? ??????????. A ????? ?????? ? automativally ????????, ??? ????? ?????????? ????? ? ?????? ??????? ???????. An (???????) ???? ?????? ???????????? ?????????, ??? ????? ???? ?????????????? ??????? ?? ???? ??????? ???????.

?????????? ??????? turtles ? ?? ????? ?? ?????????? object-oriented ????????.

?????

?? ???????? ??????????? ??? ???????? ?????? ????? ??????? ? ??????. ????????, ??????, ????? ????????? ?????? ??????????? ??????????????? ???? ??? ?? ??????? ??????.

Overview ????? ??????? ???? ?? ?????? ?????????

???????? TurtleScreen ????? ??????

Window ????????????
?????????????? ????????????
???????????? ?????? ?????????????
?????????? ?? ?????? ????????
???????? ?????? ? ???????

???????? RawTurtle ????? ???? ?? ???????????? ??????????????

??? ???? ????????? ? ????? ????? ?????????? ? ?? ???? ?????? ?????? ????.

???? ???????????????

turtle.forward(distance)
turtle.fd(distance)
Parameter: distance – a number (integer or float)

????????? ??? ?????? ????????? ??????????????, ??? ??????????? ???? ?????????? ?.

>>> turtle.position()

(0.00, 0.00)

>>> turtle.forward(25)

>>> turtle.position()

(25.00,0.00)

>>> turtle.forward(-75)

>>> turtle.position()

(-50.00,0.00)
turtle.back(distance)
turtle.bk(distance)
turtle.backward(distance)
Parameter: distance – a number

????????? ??? ??, ??? ????????????? ???, ??????? ??? ??????????? ???? ?????????? ?. ?? ????? ???? ? ??????????.

>>> turtle.position()

(0.00, 0.00)

>>> turtle.backward(30)

>>> turtle.position()

(-30.00, 0.00)
turtle.right(angle)
turtle.rt(angle)
Parameter: angle – a number (integer or float)

???? ??? ????????? ?????? ???????????. (?????????? ?? ????????? ?????????, ?????? ????? ? ????????? ??????? ??????????? (????? ?????????) ?? radians (????? ?????????) ??????????????.) ??????? ????????????? ?????? ???? ????????, ??? ????? (????? ?????????).

>>> turtle.heading()

22.0

>>> turtle.right(45)

>>> turtle.heading()

337.0
turtle.left(angle)
turtle.lt(angle)
Parameter: angle – a number (integer or float)

???? ??? ????? ?????? ???????????. (?????????? ?? ????????? ?????????, ?????? ????? ? ????????? ??????? ??????????? (????? ?????????) ?? radians (????? ?????????) ??????????????.) ??????? ????????????? ?????? ???? ????????, ??? ????? (????? ?????????).

>>> turtle.heading()

22.0

>>> turtle.left(45)

>>> turtle.heading()

67.0
turtle.goto(x, y=None)
turtle.setpos(x, y=None)
turtle.setposition(x, y=None)
Parameters:
  • x ?? ???? ??? ??????????? ? ?????
  • y – ? ?????? ??? None

??? ??y ?? ?? ??, x ???? ? ???? ????? ????????????? ??? Vec2D (?????? ? ??????????? ??????????? (????? ?????????).)

????????? ??? ???? ???????? ?????????: ??? ?????? ??????, ???? ???. ?? ????? ??? ??? ?????????????:

>>> tp = turtle.pos()

>>> tp

(0.00, 0.00)

>>> turtle.setpos(60,30)

>>> turtle.pos()

(60.00,30.00)

>>> turtle.setpos((20,80))

>>> turtle.pos()

(20.00,80.00)

>>> turtle.setpos(tp)

>>> turtle.pos()

(0.00,0.00)
turtle.setx(x)
Parameter: x – ? ?????? (??? ?? ???)

????????, ?? ??? ?????? ???????????? ? x, ???????, ??????? ??????????? ? ???????:

>>> turtle.position()

(0.00, 240.00)

>>> turtle.setx(10)

>>> turtle.position()

(10.00, 240.00)
turtle.sety(y)
Parameter: y – ? ?????? (??? ?? ???)

????????, ?? ??? ??????? ??????????? ?? y, ?????? ?????? ??????????? ? ???????:

>>> turtle.position()

(0.00, 40.00)

>>> turtle.sety(-10)

>>> turtle.position()

(0.00, -10.00)
turtle.setheading(to_angle)
turtle.seth(to_angle)
Parameter: to_angle – ? ?????? (??? ?? ???)

???????? ????????????? ???? ? to_angle. ??? ???? ????????? ?????????????? ?? ???????????:

???????? ????? logo ?????
0 – ??????? 0 – ???????
90 – ??????? 90 – ???????
180 – ????????? 180 – ?????
270 – ????? 270 – ?????????
>>> turtle.setheading(90)

>>> turtle.heading()

90
turtle.home()
????????? ??? ? ??????, ????????????? (0,0) ?? ???????? ??? ????? ? ??????? ?? ???????????? (??? ?????? ? ????????, ??? ?????? (?).
turtle.circle(radius, extent=None, steps=None)
Parameters:
  • ????????, ?? ????
  • ??????? – ? ?????? (??? None)
  • ???????, ??? ?????? ??? ? (??? None)

???????? ?? ???????, ?????? ???? ????? ????????. ???????? ??????????? ? ???????? ?????????? ?????? ? ????, ???????-? ??????? – ??????? ?, ??? ??? ? ????????? ? ????????????. If extent is not given, draw the entire circle. ??? ??????? ?? ??????? ???????, ??? ????????? ? ???? ? ???????? ???? ????????????. ???????? ???? ? ?????????? ????? ??????? ???????????, ??? ???????? ?????? ?, ??? ???? ? ?????????? ????? ??????????? ???????????. ???????? ??????????? ???? ? ?????? ????? ?????.

?????? ???????? ? approximated ?????? inscribed ???????? ???????, ?????? ????????? ???? ?????? ? ??????????: ??? ???? ????, ??? ??????????? ? ????????????. ????? ?? ??????????? ???????? ?????????? polygons.

>>> turtle.circle(50)

>>> turtle.circle(120, 180) # draw a semicircle
turtle.dot(size=None, *color)
Parameters:
  • ????, ??? ?????? ???> = 1 (??? ?????)
  • ?????, ?? colorstring ??? ?????? ?????? tuple

???????? ????????? dot ??? ????????? ??????, ???????????? ??????: ??? ?????? ?? ??????, ??? ????????????? pensize+4 ?? 2 * pensize ????????????.

>>> turtle.dot()

>>> turtle.fd(50); turtle.dot(20, "blue"); turtle.fd(50)
turtle.stamp()

????? ??? ??????? ???? ???????? ??? ???? ????? ???? ????????????. ??????????? ??? stamp_id ??? ?????, ??? ????? ? ???????? ????? ??? ????????? clearstamp (stamp_id).

>>> turtle.color("blue")

>>> turtle.stamp()

13

>>> turtle.fd(50)
turtle.clearstamp(stampid)
Parameter: stampid – ? ??? ???? ? ???? ????????? ?????? ?????? ?????? () ????

????? ?????, ?????? ???? ????? stampid.

>>> turtle.color("blue")

>>> astamp = turtle.stamp()

>>> turtle.fd(50)

>>> turtle.clearstamp(astamp)
turtle.clearstamps(n=None)
Parameter: n – ? ??? (??? None)

????? ????? ??? ???????????? ??? ?? ??? ?????????????. ??? ??n – ? ?? ??, ????? ????? ????????, ??? n> 0 ????? ?????? ????? ???????????, ?????: ??? n <0 ????? ?????? n ???????????:

>>> for i in range(8):

...  turtle.stamp(); turtle.fd(30)

>>> turtle.clearstamps(2)

>>> turtle.clearstamps(-2)

>>> turtle.clearstamps()
turtle.undo()

?????????? (???????) ?????? ???? ?????????????? (???). ?????????? ??? ???? ????? ????????????????? ???????? ? ???? ??? undobuffer.

>>> for i in range(4):

...  turtle.fd(50); turtle.lt(80)

...

>>> for i in range(8):

...  turtle.undo()
turtle.speed(speed=None)
Parameter: ???????????, ??? ?????? ??? ?: ??????????? 0.. 10 ??? ?? speedstring (??? ??????)

????????, ?? ???? ? ???????????? ????? ?????? ??? ?????? ???: ??????????? 0.. 10. ??? ??????? ??????? ? ??????, ???????? ???????? ???????????.

??? ??????? ?? ???? ??? ?, ??? 10 ??? ????? ???? ?, ??? 0.5, ????????????, ??? ????????? ? 0 – Speedstrings ?? mapped ? speedvalues ???? ???????? ????.

  • «?????????": 0
  • "????": 10
  • «??????»: 6
  • «??????»: 3
  • «Slowest»: 1

??????????????? 1 – ?? 10 – ?? ??????? ????? ?? ????? ???? ????????? ??? ???????????? ?? ???? ???????.

????????????? ???????????? = 0 ????????? ?, ?? ?? ?? ???????? ???? ? ????????. ?????? ? ???? ????? ? ?? ???????? ??? ????Right ??????? ???? ??????, ???????????.

>>> turtle.speed(3)

?????????? ???? ? ??????

turtle.position()
turtle.pos()

???????? ? ??? ????? ???????? ????? (x, y) (????? Vec2D ???????).

>>> turtle.pos()

(0.00, 240.00)
turtle.towards(x, y=None)
Parameters:
  • x ?? ???? ??? ???????????? ?? ??????, ?? ???? ??????
  • y – ?? ????, ??? x ? ??????, ????? ?? ??

???????? ???????????? ????? ???? ????? ??? ???????? ?? ??????? ????????? (x, y), ??? ??????? ??? ??? ????. ?? ?????? ? ???? ? ???????? ????????????, ??? ?????? ? ???????? "????????""???????" ??? "logo").

>>> turtle.pos()

(10.00, 10.00)

>>> turtle.towards(0,0)

225.0
turtle.xcor()

???????? ? ??? ?? ????????????? X ???????????.

>>> reset()

>>> turtle.left(60)

>>> turtle.forward(100)

>>> print turtle.xcor()

50.0
turtle.ycor()

???????? ? ??? ????? ??????????? ???????.

>>> reset()

>>> turtle.left(60)

>>> turtle.forward(100)

>>> print turtle.ycor()

86.6025403784
turtle.heading()

???????? ? ??? ????? ?????????? (?????? ?????? ? ???? ????????, ??? ?????? (?).

>>> turtle.left(67)

>>> turtle.heading()

67.0
turtle.distance(x, y=None)
Parameters:
  • x ?? ???? ??? ???????????? ?? ??????, ?? ???? ??????
  • y – ?? ????, ??? x ? ??????, ????? ?? ??

??????????? ????????????? ??? ? ??? ???? (x, y) ?? ????? ??????? ??? ????? ??? ???? ?, ???? ???? ???????????.

>>> turtle.pos()

(0.00, 0.00)

>>> turtle.distance(30,40)

50.0

>>> joe = Turtle()

>>> joe.forward(77)

>>> turtle.distance(joe)

77.0

?????????? ??????

turtle.degrees(fullcircle=360.0)
Parameter: fullcircle ?? ????

???????? ?????? ?????? ??????, ??????? `????? ???? ??" ??????????? ????? ??????? ???????. Default ?????? 360 ???????.

>>> turtle.left(90)

>>> turtle.heading()

90

>>> turtle.degrees(400.0) # angle measurement in gon

>>> turtle.heading()

100
turtle.radians()

???????? ???????????? ?????? ????????? ? radians. ???????? ????????? (2 * math.pi).

>>> turtle.heading()

90

>>> turtle.radians()

>>> turtle.heading()

1.5707963267948966

???? ????????????

????????? ??????????

turtle.pendown()
turtle.pd()
turtle.down()
????? ????? ??? – ???????????? ???????, ??? ????????.
turtle.penup()
turtle.pu()
turtle.up()
????? ???? up – ?? ???????????? ???????, ??? ????????.
turtle.pensize(width=None)
turtle.width(width=None)
Parameter: ???????????? `?????? ??????

????????, ?? ??? ???????????? ? ??????????? ??? ??????????? ???: ??? ??resizemode ????????? ? ???? ??? ?? turtleshape ? ???????, ?? ??????? ??? ??????? ????? ??? ???????????. ??? ??????? ??????? ? ??????, ???????? pensize ? ??????????:

>>> turtle.pensize()

1

>>> turtle.pensize(10) # from here on lines of width 10 are drawn
turtle.pen(pen=None, **pendict)
Parameters:
  • ???? – ? ??????? ???? ??? ????? ?????? ???????? ????????
  • pendict – ??? ??? ????? ????????? ?? ???????????, ?????? ????????? ????? ? ????? ?????????? ????????????

???????? ??? ???????????? ? ?? ???????????? ? «????????????-? ???????? ??? ???????? ???????????????? ?????????:

  • «????? ????»: ???? ?????
  • «Pendown» True????
  • «Pencolor» ?????-string, ??? ??????, tuple
  • «Fillcolor» ?????-string, ??? ??????, tuple
  • «Pensize» ?????? ??????
  • «????????????» ???? ????????? 0.. 10
  • «Resizemode" "???????" ??? "??????" ??? "noresize"
  • «Stretchfactor» (?????? ??? ?, ?????? ??? ?):
  • «???????????» ?????? ??????
  • «?????» ??????

??? dicionary ????? ? ??????????? ????? ??????? ????? ?????? ????? ??? ?????? (????? ?????????) ????????????? ?????? ???? – ??????????. ?????? ???? ??? ?? ??????, ??? ????????????? ????? ? ?????????? ???? ?????????-? ???????????. ?? ????? ? ??????????? ? ??????? ?? ???? ??????????? ???????????? ?? ?????????????? ???:

>>> turtle.pen(fillcolor="black", pencolor="red", pensize=10)

>>> turtle.pen()

{'pensize': 10, 'shown': True, 'resizemode': 'auto', 'outline': 1,

'pencolor': 'red', 'pendown': True, 'fillcolor': 'black',

'stretchfactor': (1,1), 'speed': 3}

>>> penstate=turtle.pen()

>>> turtle.color("yellow","")

>>> turtle.penup()

>>> turtle.pen()

{'pensize': 10, 'shown': True, 'resizemode': 'auto', 'outline': 1,

'pencolor': 'yellow', 'pendown': False, 'fillcolor': '',

'stretchfactor': (1,1), 'speed': 3}

>>> p.pen(penstate, fillcolor="green")

>>> p.pen()

{'pensize': 10, 'shown': True, 'resizemode': 'auto', 'outline': 1,

'pencolor': 'red', 'pendown': True, 'fillcolor': 'green',

'stretchfactor': (1,1), 'speed': 3}
turtle.isdown()

???????? ???? ?, ??? ???? ??????, ???? ?, ??? ?? ?.

>>> turtle.penup()

>>> turtle.isdown()

False

>>> turtle.pendown()

>>> turtle.isdown()

True

?????? ????????????

turtle.pencolor(*args)

???????? ??? ???????? pencolor.

???? ????????? ?????????? ??? ????????????:

pencolor()
???????? ????? pencolor ????? ???????? ???????? ??????, ???????? ?, hex-?????? ????????? ??? ??????): ????? ? ??????????? ????? ????????? ??? ?????? ????? pencolorfillcolor ?????:
pencolor(colorstring)
???????? pencolor ? colorstring, ??? tk ?????? ?????????? string, ?????? ??????, «??????», «?????», ??? "# 33cc8c".
pencolor((r, g, b))
???????? pencolor ? rgb ?????? ??????????? ?? tuple ?????????????? R, G, ?? ?. ????????????? R, G, ?? ? ???? ? ??????????? 0.. colormode, ????? colormode ??? 1.0, ??? 255 (??? colormode (????? ?????????)).
pencolor(r, g, b)
???????? pencolor ? rgb ?????? ???????????? R, G, ?? ?. ????????????? R, G, ?? ? ???? ? ??????????? 0.. colormode.

??? ??turtleshape ? ??????? ?, ????????? ??? ??????? ? ??????? ? ??? ????????? pencolor.

>>> turtle.pencolor("brown")

>>> tup = (0.2, 0.8, 0.55)

>>> turtle.pencolor(tup)

>>> turtle.pencolor()

"#33cc8c"
turtle.fillcolor(*args)

???????? ??? ??? ??fillcolor.

???? ????????? ?????????? ??? ????????????:

fillcolor()
???????? ???????? fillcolor ????? ???????? ???????? ??????, ???????? ?, hex-?????? ????????? ??? ??????): ????? ? ??????????? ????? ????????? ??? ?????? ????? pencolorfillcolor ?????:
fillcolor(colorstring)
???????? fillcolor ? colorstring, ??? tk ?????? ?????????? string, ?????? ??????, «??????», «?????», ??? "# 33cc8c".
fillcolor((r, g, b))
???????? fillcolor ? rgb ?????? ??????????? ?? tuple ?????????????? R, G, ?? ?. ????????????? R, G, ?? ? ???? ? ??????????? 0.. colormode, ????? colormode ??? 1.0, ??? 255 (??? colormode (????? ?????????)).
fillcolor(r, g, b)
???????? fillcolor ? rgb ?????? ???????????? R, G, ?? ?. ????????????? R, G, ?? ? ???? ? ??????????? 0.. colormode.

??? ??turtleshape ? ??????? ?, ?????? ??? ??????? ? ??????? ? ??? ????????? fillcolor.

>>> turtle.fillcolor("violet")

>>> col = turtle.pencolor()

>>> turtle.fillcolor(col)

>>> turtle.fillcolor(0, .5, 0)
turtle.color(*args)

???????? ??? pencolor ?? fillcolor.

?? ???? ????????? ?????????? ?? ????????????: ????? ??????????? ? 0 – ?? 3 ??????????? ???????? ????.

color()
???????? ????? pencolor ?? ???????? fillcolor ????? ????? ???????? ?????? ??????, ?????? ?????????? ? pencolor (????? ?????????) ?? fillcolor (????? ?????????).
color(colorstring), color((r,g,b)), color(r,g,b)
?????????, ???????? ?? pencolor (????, ????? ??????? ??, fillcolor ?? pencolor, ???? ????? ??????
color(colorstring1, colorstring2), color((r1,g1,b1), (r2,g2,b2))
???????? pencolor (colorstring1) ?? fillcolor (colorstring2) ?? analogously ??? ????? ???????? ???????? ????????????.

??? ??turtleshape ? ???????, ????????? ?? ???????? ??? ??????? ? ??????? ? ??? ????????? ?????????.

>>> turtle.color("red", "green")

>>> turtle.color()

("red", "green")

>>> colormode(255)

>>> color((40, 80, 120), (160, 200, 240))

>>> color()

("#285078", "#a0c8f0")

??? ???? ?????? ???????? colormode (????? ?????????).

??????????

turtle.filling()

???????? fillstate (???? ?, ??? ?????????, ???? ?????).

>>> turtle.begin_fill()

>>> if turtle.filling():

...  turtle.pensize(5)

else:

...  turtle.pensize(3)
turtle.begin_fill()

?????? ???? ???????? ? ????????? ? ?????.

>>> turtle.color("black", "red")

>>> turtle.begin_fill()

>>> turtle.circle(60)

>>> turtle.end_fill()
turtle.end_fill()
??????? ????????? ??????? ???? ?????? ????? ???????? begin_fill (????? ?????????).

More ? ???????????

turtle.reset()

????? ?? ??? ? ??????? ?? ???????, ???????????????? ??????? ? ??? ?? ???????? ????????????? ???????? ???????? ?????????.

>>> turtle.position()

(0.00,-22.00)

>>> turtle.heading()

100.0

>>> turtle.reset()

>>> turtle.position()

(0.00,0.00)

>>> turtle.heading()

0.0
turtle.clear()
????? ?? ??? ? ??????? ?? ???????: ???????? ???. ??????? ???? ??????? ????, ?????? ???? ???????? ??? turtles ??? ?????.
turtle.write(arg, move=False, align="left", font=("Arial", 8, "normal"))
Parameters:
  • arg – ??????? ? ????? ??? TurtleScreen
  • ???? – ????????
  • ????????? – ???? ??????, «???», «????????» ??? ?? "
  • ????????? ?? ????? (fontname, fontsize, fonttype)

????? – ? string ???????????????????? arg – ????? ???? ??????????? ???????? ????????? («?????», «????????» ??? ?? "), ?? ????? ???????????. ??? ???????, ???? ?, ?? ????????? ??????????? ? ???????? ?? ?????????? ????????. ????? ???????, ????? ???? ?.

>>> turtle.write("Home = ", True, align="center")

>>> turtle.write((0,0), True)

???? ??????? ??¶

????????????????

turtle.showturtle()
turtle.st()

??????? ???? ????????

>>> turtle.hideturtle()

>>> turtle.showturtle()
turtle.hideturtle()
turtle.ht()

??????? ???? ??????????. ?? ??? ??????? ? ?? ????, ??? ??? ????????? ????? ??? – ?? ???? ?????????????, ???? ?? ???????? ? ??? ??????? ?????? ???????????? observably.

>>> turtle.hideturtle()
turtle.isvisible()

???????? True ??? ???? ? ??????????, ???? ??? ?? ??????? ?.

>>> turtle.hideturtle()

>>> print turtle.isvisible():

False

??????? ????

turtle.shape(name=None)
Parameter: ?????? ?? string ??? ????? shapename

???????? ???? ????????? ? ????????? ?? ????? ????????, ???, ??? ?????? ?? ??????, ???????? ?????? ???????? ????????. ????????, ?????? ??????? ???? ? ?????????? ? TurtleScreen ? ???????? ???????. ? ??????? ???? ?? ???????? ??????? ??????????: «arrow", "????», «?????», «????????», «??????????», «??????»: ????????? ?????, ?? ?????? ??????? ?????????? ?????? ?????? ???????? register_shape (????? ?????????).

>>> turtle.shape()

"arrow"

>>> turtle.shape("turtle")

>>> turtle.shape()

"turtle"
turtle.resizemode(rmode=None)
Parameter: rmode – ???? ?????? ? ???? »,« ??? »,« noresize "

???????? resizemode ????? ??????????: «??????????», «???», «noresize". ??? ??rmode ?? ??????, ???????? ??????? resizemode. ?????? resizemodes ????? ???????? ????????????:

  • «????» ?????????? ????? ?? ??? ???????????? ?????? pensize.
  • «User» ?????????? ????? ?? ???? ??? ?????????? stretchfactor ?? outlinewidth (?????????), ????? ????????? ?? shapesize (????? ?????????).
  • «Noresize" ?? adaption ? ???? ? ????????? ???? ? ????????.

resizemode («????????») ??????? ? shapesize (????? ?????????) ??? ???????????? ???????????.

>>> turtle.resizemode("noresize")

>>> turtle.resizemode()

"noresize"
turtle.shapesize(stretch_wid=None, stretch_len=None, outline=None)
Parameters:
  • stretch_wid – ?????? ??????
  • stretch_len – ?????? ??????
  • ?????????, ?????? ??????

???????? ??? ???????????? ? ?? ???????????? xy-? stretchfactors ?? ??? ?????????. ???????? resizemode ?? ???? ??????? ?. ??? ???? ????? resizemode ????????? ? ??????? ????? ", ??? ??????????? ???? ????????, ??? ??? stretchfactors: stretch_wid ? stretchfactor ?????????? ?? ?????????????, stretch_len ? stretchfactor ? ??????????? ?? ?????????????, ????????? ????????? ???????????? ?, ?? ?????????? ?? ??????:

>>> turtle.resizemode("user")

>>> turtle.shapesize(5, 5, 12)

>>> turtle.shapesize(outline=8)
turtle.tilt(angle)
Parameter: ???????? – ? ???

???????? ? turtleshape ? ???????????? ?? ???????? ?????, ?????????, ?????? ??? ????? ???? ? ?????????? (???????????? ???????):

>>> turtle.shape("circle")

>>> turtle.shapesize(5,2)

>>> turtle.tilt(30)

>>> turtle.fd(50)

>>> turtle.tilt(30)

>>> turtle.fd(50)
turtle.settiltangle(angle)
Parameter: ???????? – ? ???

???????? ? turtleshape ?? ???? ??????????? ????? ????????????, ????? ??? ???????? ????????-? ????????????. ?? ????? ???? ? ?????????? (???????????? ???????):

>>> turtle.shape("circle")

>>> turtle.shapesize(5,2)

>>> turtle.settiltangle(45)

>>> stamp()

>>> turtle.fd(50)

>>> turtle.settiltangle(-45)

>>> stamp()

>>> turtle.fd(50)
turtle.tiltangle()

???????? ???????? ?????, ?????????, ??????? ???????????? ????? ???????????? ??? turtleshape ?? ?????????? ? ???? (??? ???????????? ???????):

>>> turtle.shape("circle")

>>> turtle.shapesize(5,2)

>>> turtle.tilt(45)

>>> turtle.tiltangle()

45

???????????? ?????????????

turtle.onclick(fun, btn=1, add=None)
Parameters:
  • fun – ? ????????? ? ????? ??????????? ??? ??????? ? ?????????????, ?? ???????? ???? ??? ????
  • NUM – ???? ?????? ??????, – ????????? ? 1 (??? ????? ????)
  • addTrue ??? ????. – ??? ?????? ?, ??? ??? ????? ?, ??????? ??????? ?? ??????????? ?????? ????????

???????? ??????? ? ???? ?????? ????????????? ????. ??? ???????? ?? ?? ????, ???? ?????? ????? ?? ????????: ?????? ??????? ????, ???????, ?????????????? ?????????:

>>> def turn(x, y):

...  left(180)

...

>>> onclick(turn) # Now clicking into the turtle will turn it.

>>> onclick(None) # event-binding will be removed
turtle.onrelease(fun, btn=1, add=None)
Parameters:
  • fun – ? ????????? ? ????? ??????????? ??? ??????? ? ?????????????, ?? ???????? ???? ??? ????
  • NUM – ???? ?????? ??????, – ????????? ? 1 (??? ????? ????)
  • addTrue ??? ????. – ??? ?????? ?, ??? ??? ????? ?, ??????? ??????? ?? ??????????? ?????? ????????

???????? ??????? ? ???? – ??????, ?????????? ????????????? ????. ??? ???????? ?? ?? ????, ???? ?????? ????? ?? ????????:

>>> class MyTurtle(Turtle):

...  def glow(self,x,y):

...  self.fillcolor("red")

...  def unglow(self,x,y):

...  self.fillcolor("")

...

>>> turtle = MyTurtle()

>>> turtle.onclick(turtle.glow) # clicking on turtle turns fillcolor red,

>>> turtle.onrelease(turtle.unglow) # releasing turns it to transparent.
turtle.ondrag(fun, btn=1, add=None)
Parameters:
  • fun – ? ????????? ? ????? ??????????? ??? ??????? ? ?????????????, ?? ???????? ???? ??? ????
  • NUM – ???? ?????? ??????, – ????????? ? 1 (??? ????? ????)
  • addTrue ??? ????. – ??? ?????? ?, ??? ??? ????? ?, ??????? ??????? ?? ??????????? ?????? ????????

???????? ??????? ?, ????, ?????????? ????????????? ????. ??? ???????? ?? ?? ????, ???? ?????? ????? ?? ????????:

???????????? ????: ???? ?????????????????? ????, ??????????-? ??????????????????? ????????? ?? ???? ?, ????????? ? ???? ?????? ??????? ??? ????.

>>> turtle.ondrag(turtle.goto)

# Subsequently, clicking and dragging the Turtle will move it across

# the screen thereby producing handdrawings (if pen is down).

?????? ???? ????????

turtle.begin_poly()
????? ??????????? ? vertices ?? ???????. ????? ???? ???????????? ?????? vertex ? ???????.
turtle.end_poly()
?????????? ??????????? ? vertices ?? ???????. ????? ???? ???????????? ?????? vertex ? ???????. ?? ????? ? ??????, ?????? vertex.
turtle.get_poly()

?????????? ?????? ??????????? ???????.

>>> p = turtle.get_poly()

>>> turtle.register_shape("myFavouriteShape", p)
turtle.clone()

??????? ?? ??????????? ? ?? clone ? ???? ??? ????? ???????, ?????????? ?? ???? ???????????????.

>>> mick = Turtle()

>>> joe = mick.clone()
turtle.getturtle()

??????????? ???? ??????? ????. ????? ??????? ????????????: ????? ?????????? ????????????? ????? ? ??????? ??? »:

>>> pet = getturtle()

>>> pet.fd(50)

>>> pet

<turtle.Turtle object at 0x01417350>

>>> turtles()

[<turtle.Turtle object at 0x01417350>]
turtle.getscreen()

??????????? TurtleScreen ?????? ? ???? ?, ????????????: TurtleScreen ????????? ????? ?????? ??? ???????.

>>> ts = turtle.getscreen()

>>> ts

<turtle.Screen object at 0x01417710>

>>> ts.bgcolor("pink")
turtle.setundobuffer(size)
Parameter: ????, ??? ?????? ??? ? ??? None

???????? ??? ??????? undobuffer. ??? ????? ? ?????? ??? ?????? undobuffer ????? ?????? ? ????????? ???? ????? ???????????? ???? ???? ??????????????????, ????? ????? ???????? ?? ????? () ???????????????????: ??? ?????? None, ?? undobuffer ? ???????? ?:

>>> turtle.setundobuffer(42)
turtle.undobufferentries()

???????? ???? ???????? ??? undobuffer.

>>> while undobufferentries():

...  undo()

???????? ????? ??????????? ???? ??????????

???????? ????????? ???? ??????????, ????? ??????? ?? ?? ???? polygons ?????? ??????, ???? ???? ? ?????????? ???????? ??????? ????????? ????? ?????? ?????????? ?? ??????:

  1. ??????? ?????? ????????? ??????? ?????? "????????????? ?.

  2. ????????? ??? ????????????????: ??? ????????, ????? ??????? ???????????? addcomponent (????? ?????????) ????????:

    ?????? `

    >>> s = Shape("compound")
    
    >>> poly1 = ((0,0),(10,-5),(0,10),(-10,-5))
    
    >>> s.addcomponent(poly1, "red", "blue")
    
    >>> poly2 = ((0,0),(10,-5),(-10,-5))
    
    >>> s.addcomponent(poly2, "blue", "red")
    
  3. ???? ????????? ????????? ? ?????? ? shapelist ?? ??? ??????????:

    >>> register_shape("myshape", s)
    
    >>> shape("myshape")
    

?????

??? ???? ???????????? ? ?????? ???? ? register_shape () ??????? ?????? ???????: ??????? ??????????? ???? ??????? ??? ???????? ???? ????? ??? ???????, ??? ??????? ????????? ?????????? ?????? ?? ????????.

???????? TurtleScreen ????? ?????? ?? ???????????? ??????????????

??? ???? ????????? ? ????? ????? ?????????? ? TurtleScreen ?????? ?????? ?????:

Window ????????????

turtle.bgcolor(*args)
Parameter: args-a string ?????? ??? ???? ????????? ??????????? 0.. colormode ??? 3-tuple ??????? ????????

????????, ?? ???????????? ???? ?????? ? TurtleScreen.

>>> screen.bgcolor("orange")

>>> screen.bgcolor()

"orange"

>>> screen.bgcolor(0.5,0,0.5)

>>> screen.bgcolor()

"#800080"
turtle.bgpic(picname=None)
Parameter: picname-a string, ????? ??? GIF, ? ???? ??? nopic », ??? None

???????? ????? ????? ??????? ??? ??????? ????????? ??????? backgroundimage. ??? ??picname ? ????? ??????, ??????? ???????????? ??????? ????? ????? ????. ??? ??picname ? «nopic" ????? ????? ??????? ?????, ??? ????. ??? ??picname ?? ?? ??, ???????? ????? ??????, ??????? backgroundimage.

>>> screen.bgpic()

"nopic"

>>> screen.bgpic("landscape.gif")

>>> screen.bgpic()

"landscape.gif"
turtle.clear()
turtle.clearscreen()

????? ????? ???????? ?? ????? turtles ?? TurtleScreen. ??????????? ? ????? ?????? TurtleScreen ? ?? ???????? ???????: ???????? ???????, ????? ????? ????? ????? ??????? ?? ????? ????? ?????????? ?????? ?? ??????????? ?????.

?????

??? TurtleScreen ?????? ???? ? ????? ?????? ???????? ????? ????? ??? clearscreen. ????????????? ??????????? ???? ?, ?????? ???????? ? ??? ?????? ???? ?.

turtle.reset()
turtle.resetscreen()

?????????? ????? Turtles ??????? ????? ????????? ????????.

?????

??? TurtleScreen ?????? ???? ? ????? ?????? ???????? ????? ????? ??? resetscreen. ????????????? ??????????? ??????????????? ??? ??? ??? ???????? ? ??? ???????? ????????????

turtle.screensize(canvwidth=None, canvheight=None, bg=None)
Parameters:
  • canvwidth – ?????? ?????? ???, ??? ???????????? ???? ? ??????
  • canvheight – ?????? ?????? ???, ??? ????????????? ???? ? ??????
  • BG-colorstring ??? ????????-tupel, ??? ????? ????? ??????

??? ????????????? ??, ???????? ??????? (canvaswidth, canvasheight). Else resize, ?????, ?? turtles ?? ????????: ?? ??????? ???????????? ?????????: ???????? ??????? ?????????? ????, ?????????? scrollbars. ??? ??????? ?????? ? ??????? ???????? ?? ??? ?????????? ?? ???????????? ????? ????? ????? ????.

>>> turtle.screensize(2000,1500)

# e.g. to search for an erroneously escaped turtle ;-)
turtle.setworldcoordinates(llx, lly, urx, ury)
Parameters:
  • llx – ? ??????, x-??????????? ?? ?????? ??? ?????????? ????
  • lly – ? ??????, y-??????????? ?? ?????? ??? ?????????? ????
  • urx – ? ??????, x-??????????? ? ????? ?? ?????????? ????
  • ury ?? ????, y-??????????? ? ????? ?? ?????????? ????

??????? ??????????? ?????? ????????? ??????????? ????????? ?? ?????? ???????? ? ???????? », ??? ????????? ?. ?? ???????? ? screen.reset (): ??? ???????, «???????» ????? ?????, ????? ??????? ?? redrawn ???????? ??? ?????????????.

????????????? ? ??????????? ?????? ????????? ????????????? ?????????? ??????????? ????? ?? ????????????.

>>> screen.reset()

>>> screen.setworldcoordinates(-50,-7.5,50,7.5)

>>> for _ in range(72):

...  left(10)

...

>>> for _ in range(8):

...  left(45); fd(2) # a regular octagon

?????????????? ????????????

turtle.delay(delay=None)
Parameter: ????????, ?????? ?????? ???

????????, ??? ??????????? ???????????? ???????? milliseconds. (?? ??????????? ??? ??????? ????????? ????? ?????????? ???????? ?????????) ????? ????? the drawing ?????????, ??? ???????????? ?????????.

????????? ???????:

>>> screen.delay(15)

>>> screen.delay()

15
turtle.tracer(n=None, delay=None)
Parameters:
  • n – nonnegative ?????? ???
  • ????????? – nonnegative ?????? ???

???? ??? ????????? ? ???????? ???????? ?, ?? ???????? ????????? ????? ????????? ???????. ??? ??n ??????, ????? ???? ? n-?? ???????? ????? ????????? ? ????????? ?????????: (?????? ? ?????????? ????????? ???????????? ??????? ?????????) ??????? ???????? ????????? ????????? ?????? (??? ????????? (????? ?????????)).

>>> screen.tracer(8, 25)

>>> dist = 2

>>> for i in range(200):

...  fd(dist)

...  rt(90)

...  dist += 2
turtle.update()
??????? ? TurtleScreen ?????????: ??????????, ??? ?????? ???? ?? ? ???????.

??? ???? RawTurtle???? ???????? ??????????? (????? ?????????).

???????????? ?????? ?????????????

turtle.listen(xdummy=None, ydummy=None)
???????? ??????????? TurtleScreen (???????? ??????? ?????????????): ???? ??????????? ??, ??????? ?????????? ?????? ???? () ? onclick ???????.
turtle.onkey(fun, key)
Parameters:
  • fun – ? ?????????, ????? ??????, ??? ????
  • Key-? string: ?????? (??????, «?») ??? ??????? ?????????? ? (??????, «??????????»)

???????? ??????? ? ??????? ???????? ??????? ????????. ??? ???????? ?? ?? ??, ??????????? ?????? ????? ?? ????????: ????????????? `??????? ???????? ???????? ??????? ?????????????, TurtleScreen ???? ? ?????????????. (??? ????? ???? ())

>>> def f():

...  fd(50)

...  lt(60)

...

>>> screen.onkey(f, "Up")

>>> screen.listen()
turtle.onclick(fun, btn=1, add=None)
turtle.onscreenclick(fun, btn=1, add=None)
Parameters:
  • fun – ? ????????? ? ????? ??????????? ??? ??????? ? ?????????????, ?? ???????? ???? ??? ????
  • NUM – ???? ?????? ??????, – ????????? ? 1 (??? ????? ????)
  • addTrue ??? ????. – ??? ?????? ?, ??? ??? ????? ?, ??????? ??????? ?? ??????????? ?????? ????????

???????? ??????? ? ???? ?????? ????????????? ???????. ??? ???????? ?? ?? ????, ???? ?????? ????? ?? ????????:

?????? ?? TurtleScreen ?????? ??????? ????? ?? ???? ?????? ??????? ????:

>>> screen.onclick(turtle.goto)

# Subsequently clicking into the TurtleScreen will

# make the turtle move to the clicked point.

>>> screen.onclick(None) # remove event binding again

?????

??? TurtleScreen ?????? ???? ? ????? ?????? ???????? ????? ????? ??? onscreenclick. ????????????? ??????????? onclick ??? ??? ??? ???????? ? ??? ???????? onclick.

turtle.ontimer(fun, t=0)
Parameters:
  • fun – ? ?????????, ????? ???????????
  • t-?? ????> = 0

???????? ??????? ?, ?? ??????? ???????? ???? ???? milliseconds.

>>> running = True

>>> def f():

 if running:

 fd(50)

 lt(60)

 screen.ontimer(f, 250)

>>> f() ### makes the turtle marching around

>>> running = False

?????????? ?? ?????? ????????

turtle.mode(mode=None)
Parameter: ????? – ???? ?????? «????????», «logo" ??? "???????"

???????? ???? ?????? («????????», «logo» ??? «???????») ?? ???????????? ???????????? ??? ??????? ?? ??????, ??????? ????? ? ??????????:

???????? «????????» – ? ?????????? ??? ????. ???????? «logo» – ? ?????????? ? ????? ????????? YerkirmediaTV ???? graphics ?????: ???????? «???????» ??????????? ? ??????????? ?????? ????????? «?????????? ???????????»: ?????????????: ??? ???????? ???????????? ??????? ???????????? ?, ??? xy ???????-?????????????????? ?? ??????? 1.

????? ????????? ???? ???? ?????? ???????????
"????????" ?? (???????) ?????????? ????? ??????? ???????????
"Logo" ??? (???????) ?????????? ????? ???????????
>>> mode("logo") # resets turtle heading to north

>>> mode()

"logo"
turtle.colormode(cmode=None)
Parameter: cmode ???? ????????? 1.0, ??? 255

??????????? colormode ??? ??? ??1.0 ??? 255. ?????????? r, ?, ? ????????? ???????? triples ???? ? ????: ??????????? 0.. cmode.

>>> screen.colormode()

1.0

>>> screen.colormode(255)

>>> turtle.pencolor(240,160,80)
turtle.getcanvas()

??????????? ????? ??? TurtleScreen. ??????? insiders, ????? ?????, ?? ??? ???? ?? Tkinter ????.

>>> cv = screen.getcanvas()

>>> cv

<turtle.ScrolledCanvas instance at 0x010742D8>
turtle.getshapes()

???????? ??????? ?????????? ????? ?????????? ???? ???? ??????????.

>>> screen.getshapes()

["arrow", "blank", "circle",..., "turtle"]
turtle.register_shape(name, shape=None)
turtle.addshape(name, shape=None)

???? ?? ???? ?????? ????????? ?? ?????????? ??? ???????????:

  1. ?????? ? ?????? ?? GIF, ?? ?????, ?? ???? ????? ?? ??: ???????? ???????????? ??????? ?????????.

    ?????

    ?????????? ?????????? ??? ?????, ??? ??????? ?? ???, ?????? ?? ????? ??? ????????? ?????????? ? ???.

  2. ????? ? ????????? string ?? ???? ??????????? ? tuple ????? ?????????????: ???????? ???????????? ??????? ?????????.

  3. ????? ? ????????? string ?? ??? ?? (????) ???? ??????: ???????? ???????????? ????????????? ?????????.

????????? ???? ????????? ? TurtleScreen ? shapelist. ????? thusly ???????? ?????????? ????? ?? ?????? ????? ???????? ????????? (shapename).

>>> screen.register_shape("turtle.gif")

>>> screen.register_shape("triangle", ((5,-3), (0,5), (-5,-3)))
turtle.turtles()

???????? ????? turtles ?????????? ???????.

>>> for turtle in screen.turtles()

...  turtle.color("red")
turtle.window_height()¶

???????? ??????????? ??? ???? ??????????

>>> screen.window_height()

480
turtle.window_width()

??????????? ???????????? ? ???? ??????????

>>> screen.window_width()

640

???????? ?????? ?? ???????, ?? ?? ???????? TurtleScreen

turtle.bye()
????? ?? turtlegraphics ?????????:
turtle.exitonclick()

???????? bye () ????? ? ???? ?????????? ???????.

??? ???????? "using_IDLE» – ? ??????????? ?????????? ??? ???? (???????? ??????), ???????? ?????? mainloop. ???????????? ????: ??? idle ??? - ? ??? (no subprocess) ???????????? ?, ??? ?????? ???? ? ???? ?????? ? turtle.cfg. ??? ??????? ????? ??????? mainloop ????? ? ???? ???????????? ????????.

turtle.setup(width=_CFG[, "width"], height=_CFG[, "height"], startx=_CFG[, "leftright"], starty=_CFG[, "topbottom"])

???????? ???? ?? ????? ???????? ????????? ??? ????????? ??????????? ??????? ?? ??????????? dicionary ?? ????? ? ???????? ??????? turtle.cfg ?????.

Parameters:
  • ???????????? `??? ?????? ??? ?, ???? ??? ??????, ??? ???, ?? ???? ???????. default` 50% – ?, ??????
  • ?????????????, ??? ?????? ??? ?, ????????????? ?????? ?, ??? ?? ???, ?? ???? ???????, default-? 75% – ?, ??????
  • startx – ??? ??????, ????? ????? ?????????? ??? ????? ??????, ??? ????????? ? ?? ?????, ??? ?? ????, ??????? ???????? ???????????
  • startx – ??? ??????, ????? ????? ?????????? ????? ????? ??????, ??? ????????? ? ?????? ?????, ??? ?? ????, ??????? ???????? ??????????
>>> screen.setup (width=200, height=200, startx=0, starty=0)

# sets window to 200x200 pixels, in upper left of screen

>>> screen.setup(width=.75, height=0.5, startx=None, starty=None)

# sets window to 75% of screen by 50% of screen and centers
turtle.title(titlestring)
Parameter: titlestring-a string, ??? ????? ? ????? titlebar ? ???? ???????? ???????????

???????? ?????? ???? ?????????? titlestring.

>>> screen.title("Welcome to the turtle zoo!")

??????????? ??????????? ??????? ????

class turtle.RawTurtle(canvas)
class turtle.RawPen(canvas)
Parameter: canvas
a Tkinter.Canvas, a ScrolledCanvas or a
TurtleScreen

??????? ???. The ???? ???? ????? ?????????, ???? ?????????? ? ????? «????????? ???? ????? RawTurtle".

class turtle.Turtle
??????? ? RawTurtle, ???? ????? ??????????, ???? ?? – ??? ? ???????? ?????? ??????? ???????? ? ??????? ??????, ??? ????????? ? ?????? ?????:
class turtle.TurtleScreen(cv)
Parameter: cv – a Tkinter.Canvas

????????? ? ?????? ??????? ???? ????????? setbg (????? ?????????) ?? ???? ????? ?????????? ?? ????????:

class turtle.Screen
??????? ? TurtleScreen ??? ???? ?????????? ?????????.
class turtle.ScrolledCavas(master)
Parameter: master – ?? Tkinter widget ? ????????? ScrolledCanvas, ???????, ?? ???? ? scrollbars Tkinter ? ?????????

???????????? ? ?????????? ???????, ??? ???????? ??????? ?????? ????????? ? ScrolledCanvas ????? ??????????????? ????? turtles.

class turtle.Shape(type_, data)
Parameter: type_ – ???? ?????? ? ??????? »,« ??????? »,« ???? »:

????????? ??????????? ???????????? ?????????? ?. The ????? (type_ ?????????) ???? ? ??????? ??? ????????:

type_ ????????
«???????» ? ???????-tuple, ???????, ?? tuple ?? ???????? ?? ?????????????
"???????" ?????? (??? ???? ????? ??????!)
"????" ??? (??? compund ???? ???? ? ????????, ???????????? addcomponent () ???????):
addcomponent (poly, ???????, ????????? = None-)
Parameters:
  • poly – ? ???????, ???????, ?? tuple ?? ????? ?????
  • ??????? ?? ?????, ?? poly ? ?????
  • ?????????, ?? ?????? ????? poly ? ?????? (??? ?????)

Example:

>>> poly = ((0,0),(10,-5),(0,10),(-10,-5))

>>> s = Shape("compound")

>>> s.addcomponent(poly, "red", "blue")

#.. add more components and then use register_shape()

??? ???????? ????? ??????????? ???? ??????????.

class turtle.Vec2D(x, y)

A ????? ????????? ??????? ?????, ???????????? ? ????? ???????? ???? ??????????? ????? ???? ???????. ????? ? ??????? ????? ???? ????????? ????????? ??. ???????? tuple, ?????? ?? ?? ??????? ? tuple.

????????? ????? (A, B vectors, k ??????):

  • ?+ ? ?????? ????????
  • ? ? ?????? ??????
  • ? * ? ?????? ????????
  • k * A * k ?? ???????????? ? scalar
  • ABS (?) ???????? ????? of a
  • a.rotate (????????) ???????

?????????? ?? ?????????????

?????? ?????? ?????????

??????????? ????????? ??????? ?? ???? ????? ?? ?????????? ???????? ??????? docstrings. ???????? ????? ????? ?? ??????????? ????? ??????-? ????????? ??????? Python – ????? ??????????????????:

  • ???????? idle, tooltips ????? ?????????????????? ?? ?????? ?????? docstrings ? ????? ? function-/method ???????.

  • ??????????? ??????????? (????? ?????????) ??? ????????? ??? ?????????????? ?????????? ? docstrings:

    >>> help(Screen.bgcolor)
    
    Help on method bgcolor in module turtle:
    
    bgcolor(self, *args) unbound turtle.Screen method
    
     Set or return backgroundcolor of the TurtleScreen.
    
     Arguments (if given): a color string or three numbers
    
     in the range 0..colormode or a 3-tuple of such numbers.
    
     >>> screen.bgcolor("orange")
    
     >>> screen.bgcolor()
    
     "orange"
    
     >>> screen.bgcolor(0.5,0,0.5)
    
     >>> screen.bgcolor()
    
     "#800080"
    
    >>> help(Turtle.penup)
    
    Help on method penup in module turtle:
    
    penup(self) unbound turtle.Turtle method
    
     Pull the pen up -- no drawing when moving.
    
     Aliases: penup | pu | up
    
     No argument
    
     >>> turtle.penup()
    
  • ??? docstrings ?? ?????????????? ????? ??????? ??????????? ??, ? ???????? ???????? ??????? `

    >>> help(bgcolor)
    
    Help on function bgcolor in module turtle:
    
    bgcolor(*args)
    
     Set or return backgroundcolor of the TurtleScreen.
    
     Arguments (if given): a color string or three numbers
    
     in the range 0..colormode or a 3-tuple of such numbers.
    
     Example::
    
     >>> bgcolor("orange")
    
     >>> bgcolor()
    
     "orange"
    
     >>> bgcolor(0.5,0,0.5)
    
     >>> bgcolor()
    
     "#800080"
    
    >>> help(penup)
    
    Help on function penup in module turtle:
    
    penup()
    
     Pull the pen up -- no drawing when moving.
    
     Aliases: penup | pu | up
    
     No argument
    
     Example:
    
     >>> penup()
    

??? ?????????? docstrings ????????? ?? ??????? ?????? ??? ?????? ??????? ????????????, ????? ??????? ?? ????????? ?????????? ???????:

?????????????? docstrings ?????? ??????????

?? ??????? ??????? ??????? ?????????? ????? ??????? ???????????? ?? ?????????, ????? ?? docstrings ?? ??????????? ????????? ?????? ?????? ?? ????.

turtle.write_docstringdict(filename="turtle_docstringdict")
Parameter: ?????-a string, ????? ????? ????????????

??????? ?? ???? docstring-? ??????? ?? python ????? ???????, ?????? ???? ????? ????? ????????????: ??? ????????? ???? ? ????????? ??????? (??? ?? ???????????? ?? ??? ????????? ??????). The docstring ??????? ????? ???? ?????? python ????? ????????? ????? ????????????: PY. ??? ?????????? ? ??????? ????? ??????? ????? ????????????? ??????? docstrings ??? ?????? ??????????.

??? ?????? (??? ??? ???????????), ????????? ? ?????????? ???, ?????? ???? ?? – ???? ????????? ??? ??????? ??????, ???? ???? ? ????????? ??? docstrings ?? ???????? ?? ????????? ????? ????? ?????? turtle_docstringdict_german.py.

??? ?????? ????? ????? ???????????? ?????? ??? turtle.cfg ????? ??? ???????? ?? ???????? ? ?????????? ????????? ?? ????????? ???????? ???????? docstrings.

????????? ???????, ??? ?????? ??? docstring ??????????? ??? ?????????? ?? ????????. (Requests ??????? ??? glingl ????????????????? aon - ??):

?????? ?????????? ?????? ?? Turtles

The ???????????? default ????????????? mimics ????? ?? ???????? ??? ???? ??????? ??????? ???????? ???? ????????? ?????????????????? ??? ???.

??? ??????????? ?? ?????????? ??? ??????????????, ??? ????? ??? ? ?????????? ??? ????????????: ??? ??????? ??? ???? ????? ??? ? ??????????????? ??? ???????????, ?????? ?????? ??????????? ????? ?? ??????????, ????? ?? ????????? ???????? ????? turtle.cfg ??? ???????? ? ?????????? ??????? ?? ??? ???????????????? ?????????????, ??? ??? ????????:

??? ????????? ? ????????????????, ?? ??????????????? ?? ???????? turtle.cfg:

width = 0.5

height = 0.75

leftright = None

topbottom = None

canvwidth = 400

canvheight = 300

mode = standard

colormode = 1.0

delay = 10

undobuffersize = 1000

shape = classic

pencolor = black

fillcolor = black

resizemode = noresize

visible = True

language = english

exampleturtle = turtle

examplescreen = screen

title = Python Turtle Graphics

using_IDLE = False

???? ?????????????? ??????? ????????:

  • ?????? ???? ?????? ??????????????? ??????????? ?????????? Screen.setup () ???????.
  • Line 5 ?? 6 ??????????????? ??????????? ?????????? ???????? Screen.screensize ():
  • ???? ????? ? ????? ????? ???? ???????????? ??????????, ?????? ?????? ???, ???? ?? ????: ????????? ???????????????? ?????? ??????????? (????).
  • ??? ??????????? ?? ??????????, ?? fillcolor (??????? ??????? ???????? ????), ???? ???? ? ???? fillcolor = "" (?????? ????? nonempty strings ????? ? ?????? ?????? ?? cfg-? ????):
  • ??? ??????????? ?? ?????????? ?? ??? ?? ??????, ???? ???? ? ?????????? resizemode = ????.
  • ??? ??????????? ? ?????? ?????? = ???????? ? docstringdict turtle_docstringdict_italian.py ????? ??????? ? ?????????? ???????, ??? ???? ? ?????????? ??????????, ??????, ????? ?????????????? ????? ????.
  • ??? ???????????? exampleturtle ?? examplescreen ????????? ?????????, ??? ????????????, ???? ?? ????? ???????? ?? docstrings. The ??????????? ??????-? docstrings ????????-? docstrings ????? ????? ??? ????????? ?? docstrings.
  • using_IDLE: ????????, ?? ?? ???? ?, ??? ???? ?????????? ???????? ????? ?? ???-n (??? «?? subprocess»): ?? ???????? exitonclick (????? ?????????) ????? mainloop.

?????? ????? ? ????? turtle.cfg ???? ????????????, ????? ??????? ???? ?? ????????? ??? ? ??????? ???????????? ????????????. ??????? ?? ??????? ??????????? ?????? ????.

The Demo???? ?????????? ??????????? ? turtle.cfg ?????. ???? ????? ?? ????????????? ??? ????? ??????, ?? ??? ????????????, ??? ????? ? ???? ???????????? (??????? ? ?? ?? ??????? ?????? ????-?):

???? ?????????

?? ?? ???? ???? ????????? ? turtledemo ?????????? ??????? ? ???????? ???????????? ??????? ????????

??? ??????????? ? `

  • ?? ????????? 15 ???? ????????? ??????????? differet ???????????? ??? ??????? ????
  • ? demo viewer turtleDemo.py ??? ????? ? ??????????? ??????? sourcecode ?? ?????????, ?? ?????? ?? ??????????. 14 – ??????????? ?????? ??????? ??????????? ?????, ?????? ?? ????? ?? ?????????? standalone.
  • ??? ??????? ????? ? turtledemo_two_canvases.py ???????????? ???????????? ????? ??????? ??? ??? ???????. ?????? ??, ?? ????? ????? ? ?????????? standalone.
  • ?? turtle.cfg ???? ??? ????????????, ??? ???? ???????? ? ????? ??????, ?? ?????? ???? ?? ?????????? ??? ???????.

??? demoscripts ??

????? ?????????????? ??????????????
bytedesign ??????? ??????? ?????? turtlegraphics ????????? (), ????????, ????????? ()
???? ?????????? verhust ?????????? ?? ?????????? ?, ?? ???? ???? ?? ??????? ?????????????? ????? ?????????? ????????????? ???????????
????????? ?????????? ?????????? ????? ??????? ??? ??????????? turtles ????? ?????????? ??????? ?, ontimer
colormixer ???? ? R, G, ? ondrag ()
fractalcurves Hilbert & Koch ????? ?????????
lindenmayer ethnomathematics (???????? kolams) L-????????
minimal_hanoi Towers ?? Hanoi ??????????? Turtles ????? Hanoi ????????????? (????????, shapesize)
?????? ?????????????? minimalistic ? ??????? onclick()
???????????? ???????? ????: ????? ?? ?????????
penrose aperiodic ???????? ???? ? kites ?? ????? stamp()
planet_and_moon ???????????? gravitational ????????? ???? ??????????, Vec2D
??? ? (??????????) ??????????? ?????? ???? (???????????? ?????????????) clone()
?????????, ???? ???????????? ?? ??????? ??????????? ??????? ???? ????????? clone(), undo()
yingyang ??? ???????? ?????? circle()

?????????:

????, ????? python ????? 2,6

  • ??? ????????? Turtle.tracer (), Turtle.window_width () ?? Turtle.window_height () ????????. ???????? ?? ??? ????????? ?? ????????? ???? ???????? ? ????? ????? ????????? ???????. ?????????????? ??????? ????? ????? ?? ?????????? ?: (? ??? ????? python ????? 2,6 ??? ????????? ???? ?? ???? duplications ???????????? TurtleScreen ???????? ?????? -? ?????????)
  • ??????? Turtle.fill () ? ???????. ????????? begin_fill (????? ?????????) ?? end_fill (????? ?????????) ???? – ??? ?????? ?: ???? ???? ????????? `?????????? ???? ? ??????? ??? end_fill (????? ?????????) ?????.
  • ????? Turtle.filling () ????? ????????? ?: ??? ???????????? ? ??????? ??????: ???? ?, ??? ??????? ?????????? ????????, ???? ??. ??? ???????? ??????????????? ? ??????? () ???? `????? ??????????? ?????????? python ????? 2.6.

Comments are closed.