Debian Codegraph @

jedi/third_party/typeshed/stdlib/turtle.pyi

raw symbols SCIP
1 import sys
2 from _typeshed import StrPath
3 from collections.abc import Callable, Generator, Sequence
4 from contextlib import contextmanager
5 from tkinter import Canvas, Frame, Misc, PhotoImage, Scrollbar
6 from typing import Any, ClassVar, Literal, TypedDict, overload, type_check_only
7 from typing_extensions import Self, TypeAlias, deprecated, disjoint_base
8
9 __all__ = [
10 "ScrolledCanvas",
11 "TurtleScreen",
12 "Screen",
13 "RawTurtle",
14 "Turtle",
15 "RawPen",
16 "Pen",
17 "Shape",
18 "Vec2D",
19 "addshape",
20 "bgcolor",
21 "bgpic",
22 "bye",
23 "clearscreen",
24 "colormode",
25 "delay",
26 "exitonclick",
27 "getcanvas",
28 "getshapes",
29 "listen",
30 "mainloop",
31 "mode",
32 "numinput",
33 "onkey",
34 "onkeypress",
35 "onkeyrelease",
36 "onscreenclick",
37 "ontimer",
38 "register_shape",
39 "resetscreen",
40 "screensize",
41 "setup",
42 "setworldcoordinates",
43 "textinput",
44 "title",
45 "tracer",
46 "turtles",
47 "update",
48 "window_height",
49 "window_width",
50 "back",
51 "backward",
52 "begin_fill",
53 "begin_poly",
54 "bk",
55 "circle",
56 "clear",
57 "clearstamp",
58 "clearstamps",
59 "clone",
60 "color",
61 "degrees",
62 "distance",
63 "dot",
64 "down",
65 "end_fill",
66 "end_poly",
67 "fd",
68 "fillcolor",
69 "filling",
70 "forward",
71 "get_poly",
72 "getpen",
73 "getscreen",
74 "get_shapepoly",
75 "getturtle",
76 "goto",
77 "heading",
78 "hideturtle",
79 "home",
80 "ht",
81 "isdown",
82 "isvisible",
83 "left",
84 "lt",
85 "onclick",
86 "ondrag",
87 "onrelease",
88 "pd",
89 "pen",
90 "pencolor",
91 "pendown",
92 "pensize",
93 "penup",
94 "pos",
95 "position",
96 "pu",
97 "radians",
98 "right",
99 "reset",
100 "resizemode",
101 "rt",
102 "seth",
103 "setheading",
104 "setpos",
105 "setposition",
106 "setundobuffer",
107 "setx",
108 "sety",
109 "shape",
110 "shapesize",
111 "shapetransform",
112 "shearfactor",
113 "showturtle",
114 "speed",
115 "st",
116 "stamp",
117 "tilt",
118 "tiltangle",
119 "towards",
120 "turtlesize",
121 "undo",
122 "undobufferentries",
123 "up",
124 "width",
125 "write",
126 "xcor",
127 "ycor",
128 "write_docstringdict",
129 "done",
130 "Terminator",
131 ]
132
133 if sys.version_info >= (3, 14):
134 __all__ += ["fill", "no_animation", "poly", "save"]
135
136 if sys.version_info >= (3, 12):
137 __all__ += ["teleport"]
138
139 if sys.version_info < (3, 13):
140 __all__ += ["settiltangle"]
141
142 # Note: '_Color' is the alias we use for arguments and _AnyColor is the
143 # alias we use for return types. Really, these two aliases should be the
144 # same, but as per the "no union returns" typeshed policy, we'll return
145 # Any instead.
146 _Color: TypeAlias = str | tuple[float, float, float]
147 _AnyColor: TypeAlias = Any
148
149 @type_check_only
150 class _PenState(TypedDict):
151 shown: bool
152 pendown: bool
153 pencolor: _Color
154 fillcolor: _Color
155 pensize: int
156 speed: int
157 resizemode: Literal["auto", "user", "noresize"]
158 stretchfactor: tuple[float, float]
159 shearfactor: float
160 outline: int
161 tilt: float
162
163 _Speed: TypeAlias = str | float
164 _PolygonCoords: TypeAlias = Sequence[tuple[float, float]]
165
166 if sys.version_info >= (3, 12):
167 class Vec2D(tuple[float, float]):
168 def __new__(cls, x: float, y: float) -> Self: ...
169 def __add__(self, other: tuple[float, float]) -> Vec2D: ... # type: ignore[override]
170 @overload # type: ignore[override]
171 def __mul__(self, other: Vec2D) -> float: ...
172 @overload
173 def __mul__(self, other: float) -> Vec2D: ...
174 def __rmul__(self, other: float) -> Vec2D: ... # type: ignore[override]
175 def __sub__(self, other: tuple[float, float]) -> Vec2D: ...
176 def __neg__(self) -> Vec2D: ...
177 def __abs__(self) -> float: ...
178 def rotate(self, angle: float) -> Vec2D: ...
179
180 else:
181 @disjoint_base
182 class Vec2D(tuple[float, float]):
183 def __new__(cls, x: float, y: float) -> Self: ...
184 def __add__(self, other: tuple[float, float]) -> Vec2D: ... # type: ignore[override]
185 @overload # type: ignore[override]
186 def __mul__(self, other: Vec2D) -> float: ...
187 @overload
188 def __mul__(self, other: float) -> Vec2D: ...
189 def __rmul__(self, other: float) -> Vec2D: ... # type: ignore[override]
190 def __sub__(self, other: tuple[float, float]) -> Vec2D: ...
191 def __neg__(self) -> Vec2D: ...
192 def __abs__(self) -> float: ...
193 def rotate(self, angle: float) -> Vec2D: ...
194
195 # Does not actually inherit from Canvas, but dynamically gets all methods of Canvas
196 class ScrolledCanvas(Canvas, Frame): # type: ignore[misc]
197 bg: str
198 hscroll: Scrollbar
199 vscroll: Scrollbar
200 def __init__(
201 self, master: Misc | None, width: int = 500, height: int = 350, canvwidth: int = 600, canvheight: int = 500
202 ) -> None: ...
203 canvwidth: int
204 canvheight: int
205 def reset(self, canvwidth: int | None = None, canvheight: int | None = None, bg: str | None = None) -> None: ...
206
207 class TurtleScreenBase:
208 cv: Canvas
209 canvwidth: int
210 canvheight: int
211 xscale: float
212 yscale: float
213 def __init__(self, cv: Canvas) -> None: ...
214 def mainloop(self) -> None: ...
215 def textinput(self, title: str, prompt: str) -> str | None: ...
216 def numinput(
217 self, title: str, prompt: str, default: float | None = None, minval: float | None = None, maxval: float | None = None
218 ) -> float | None: ...
219
220 class Terminator(Exception): ...
221 class TurtleGraphicsError(Exception): ...
222
223 class Shape:
224 def __init__(
225 self, type_: Literal["polygon", "image", "compound"], data: _PolygonCoords | PhotoImage | None = None
226 ) -> None: ...
227 def addcomponent(self, poly: _PolygonCoords, fill: _Color, outline: _Color | None = None) -> None: ...
228
229 class TurtleScreen(TurtleScreenBase):
230 def __init__(
231 self, cv: Canvas, mode: Literal["standard", "logo", "world"] = "standard", colormode: float = 1.0, delay: int = 10
232 ) -> None: ...
233 def clear(self) -> None: ...
234 @overload
235 def mode(self, mode: None = None) -> str: ...
236 @overload
237 def mode(self, mode: Literal["standard", "logo", "world"]) -> None: ...
238 def setworldcoordinates(self, llx: float, lly: float, urx: float, ury: float) -> None: ...
239 def register_shape(self, name: str, shape: _PolygonCoords | Shape | None = None) -> None: ...
240 @overload
241 def colormode(self, cmode: None = None) -> float: ...
242 @overload
243 def colormode(self, cmode: float) -> None: ...
244 def reset(self) -> None: ...
245 def turtles(self) -> list[Turtle]: ...
246 @overload
247 def bgcolor(self) -> _AnyColor: ...
248 @overload
249 def bgcolor(self, color: _Color) -> None: ...
250 @overload
251 def bgcolor(self, r: float, g: float, b: float) -> None: ...
252 @overload
253 def tracer(self, n: None = None) -> int: ...
254 @overload
255 def tracer(self, n: int, delay: int | None = None) -> None: ...
256 @overload
257 def delay(self, delay: None = None) -> int: ...
258 @overload
259 def delay(self, delay: int) -> None: ...
260 if sys.version_info >= (3, 14):
261 @contextmanager
262 def no_animation(self) -> Generator[None]: ...
263
264 def update(self) -> None: ...
265 def window_width(self) -> int: ...
266 def window_height(self) -> int: ...
267 def getcanvas(self) -> Canvas: ...
268 def getshapes(self) -> list[str]: ...
269 def onclick(self, fun: Callable[[float, float], object], btn: int = 1, add: bool | None = None) -> None: ...
270 def onkey(self, fun: Callable[[], object], key: str) -> None: ...
271 def listen(self, xdummy: float | None = None, ydummy: float | None = None) -> None: ...
272 def ontimer(self, fun: Callable[[], object], t: int = 0) -> None: ...
273 @overload
274 def bgpic(self, picname: None = None) -> str: ...
275 @overload
276 def bgpic(self, picname: str) -> None: ...
277 @overload
278 def screensize(self, canvwidth: None = None, canvheight: None = None, bg: None = None) -> tuple[int, int]: ...
279 # Looks like if self.cv is not a ScrolledCanvas, this could return a tuple as well
280 @overload
281 def screensize(self, canvwidth: int, canvheight: int, bg: _Color | None = None) -> None: ...
282 if sys.version_info >= (3, 14):
283 def save(self, filename: StrPath, *, overwrite: bool = False) -> None: ...
284 onscreenclick = onclick
285 resetscreen = reset
286 clearscreen = clear
287 addshape = register_shape
288 def onkeypress(self, fun: Callable[[], object], key: str | None = None) -> None: ...
289 onkeyrelease = onkey
290
291 class TNavigator:
292 START_ORIENTATION: dict[str, Vec2D]
293 DEFAULT_MODE: str
294 DEFAULT_ANGLEOFFSET: int
295 DEFAULT_ANGLEORIENT: int
296 def __init__(self, mode: Literal["standard", "logo", "world"] = "standard") -> None: ...
297 def reset(self) -> None: ...
298 def degrees(self, fullcircle: float = 360.0) -> None: ...
299 def radians(self) -> None: ...
300 if sys.version_info >= (3, 12):
301 def teleport(self, x: float | None = None, y: float | None = None, *, fill_gap: bool = False) -> None: ...
302
303 def forward(self, distance: float) -> None: ...
304 def back(self, distance: float) -> None: ...
305 def right(self, angle: float) -> None: ...
306 def left(self, angle: float) -> None: ...
307 def pos(self) -> Vec2D: ...
308 def xcor(self) -> float: ...
309 def ycor(self) -> float: ...
310 @overload
311 def goto(self, x: tuple[float, float], y: None = None) -> None: ...
312 @overload
313 def goto(self, x: float, y: float) -> None: ...
314 def home(self) -> None: ...
315 def setx(self, x: float) -> None: ...
316 def sety(self, y: float) -> None: ...
317 @overload
318 def distance(self, x: TNavigator | tuple[float, float], y: None = None) -> float: ...
319 @overload
320 def distance(self, x: float, y: float) -> float: ...
321 @overload
322 def towards(self, x: TNavigator | tuple[float, float], y: None = None) -> float: ...
323 @overload
324 def towards(self, x: float, y: float) -> float: ...
325 def heading(self) -> float: ...
326 def setheading(self, to_angle: float) -> None: ...
327 def circle(self, radius: float, extent: float | None = None, steps: int | None = None) -> None: ...
328 def speed(self, s: int | None = 0) -> int | None: ...
329 fd = forward
330 bk = back
331 backward = back
332 rt = right
333 lt = left
334 position = pos
335 setpos = goto
336 setposition = goto
337 seth = setheading
338
339 class TPen:
340 def __init__(self, resizemode: Literal["auto", "user", "noresize"] = "noresize") -> None: ...
341 @overload
342 def resizemode(self, rmode: None = None) -> str: ...
343 @overload
344 def resizemode(self, rmode: Literal["auto", "user", "noresize"]) -> None: ...
345 @overload
346 def pensize(self, width: None = None) -> int: ...
347 @overload
348 def pensize(self, width: int) -> None: ...
349 def penup(self) -> None: ...
350 def pendown(self) -> None: ...
351 def isdown(self) -> bool: ...
352 @overload
353 def speed(self, speed: None = None) -> int: ...
354 @overload
355 def speed(self, speed: _Speed) -> None: ...
356 @overload
357 def pencolor(self) -> _AnyColor: ...
358 @overload
359 def pencolor(self, color: _Color) -> None: ...
360 @overload
361 def pencolor(self, r: float, g: float, b: float) -> None: ...
362 @overload
363 def fillcolor(self) -> _AnyColor: ...
364 @overload
365 def fillcolor(self, color: _Color) -> None: ...
366 @overload
367 def fillcolor(self, r: float, g: float, b: float) -> None: ...
368 @overload
369 def color(self) -> tuple[_AnyColor, _AnyColor]: ...
370 @overload
371 def color(self, color: _Color) -> None: ...
372 @overload
373 def color(self, r: float, g: float, b: float) -> None: ...
374 @overload
375 def color(self, color1: _Color, color2: _Color) -> None: ...
376 if sys.version_info >= (3, 12):
377 def teleport(self, x: float | None = None, y: float | None = None, *, fill_gap: bool = False) -> None: ...
378
379 def showturtle(self) -> None: ...
380 def hideturtle(self) -> None: ...
381 def isvisible(self) -> bool: ...
382 # Note: signatures 1 and 2 overlap unsafely when no arguments are provided
383 @overload
384 def pen(self) -> _PenState: ...
385 @overload
386 def pen(
387 self,
388 pen: _PenState | None = None,
389 *,
390 shown: bool = ...,
391 pendown: bool = ...,
392 pencolor: _Color = ...,
393 fillcolor: _Color = ...,
394 pensize: int = ...,
395 speed: int = ...,
396 resizemode: Literal["auto", "user", "noresize"] = ...,
397 stretchfactor: tuple[float, float] = ...,
398 outline: int = ...,
399 tilt: float = ...,
400 ) -> None: ...
401 width = pensize
402 up = penup
403 pu = penup
404 pd = pendown
405 down = pendown
406 st = showturtle
407 ht = hideturtle
408
409 class RawTurtle(TPen, TNavigator): # type: ignore[misc] # Conflicting methods in base classes
410 screen: TurtleScreen
411 screens: ClassVar[list[TurtleScreen]]
412 def __init__(
413 self,
414 canvas: Canvas | TurtleScreen | None = None,
415 shape: str = "classic",
416 undobuffersize: int = 1000,
417 visible: bool = True,
418 ) -> None: ...
419 def reset(self) -> None: ...
420 def setundobuffer(self, size: int | None) -> None: ...
421 def undobufferentries(self) -> int: ...
422 def clear(self) -> None: ...
423 def clone(self) -> Self: ...
424 @overload
425 def shape(self, name: None = None) -> str: ...
426 @overload
427 def shape(self, name: str) -> None: ...
428 # Unsafely overlaps when no arguments are provided
429 @overload
430 def shapesize(self) -> tuple[float, float, float]: ...
431 @overload
432 def shapesize(
433 self, stretch_wid: float | None = None, stretch_len: float | None = None, outline: float | None = None
434 ) -> None: ...
435 @overload
436 def shearfactor(self, shear: None = None) -> float: ...
437 @overload
438 def shearfactor(self, shear: float) -> None: ...
439 # Unsafely overlaps when no arguments are provided
440 @overload
441 def shapetransform(self) -> tuple[float, float, float, float]: ...
442 @overload
443 def shapetransform(
444 self, t11: float | None = None, t12: float | None = None, t21: float | None = None, t22: float | None = None
445 ) -> None: ...
446 def get_shapepoly(self) -> _PolygonCoords | None: ...
447
448 if sys.version_info < (3, 13):
449 @deprecated("Deprecated since Python 3.1; removed in Python 3.13. Use `tiltangle()` instead.")
450 def settiltangle(self, angle: float) -> None: ...
451
452 @overload
453 def tiltangle(self, angle: None = None) -> float: ...
454 @overload
455 def tiltangle(self, angle: float) -> None: ...
456 def tilt(self, angle: float) -> None: ...
457 # Can return either 'int' or Tuple[int, ...] based on if the stamp is
458 # a compound stamp or not. So, as per the "no Union return" policy,
459 # we return Any.
460 def stamp(self) -> Any: ...
461 def clearstamp(self, stampid: int | tuple[int, ...]) -> None: ...
462 def clearstamps(self, n: int | None = None) -> None: ...
463 def filling(self) -> bool: ...
464 if sys.version_info >= (3, 14):
465 @contextmanager
466 def fill(self) -> Generator[None]: ...
467
468 def begin_fill(self) -> None: ...
469 def end_fill(self) -> None: ...
470 @overload
471 def dot(self, size: int | _Color | None = None) -> None: ...
472 @overload
473 def dot(self, size: int | None, color: _Color, /) -> None: ...
474 @overload
475 def dot(self, size: int | None, r: float, g: float, b: float, /) -> None: ...
476 def write(
477 self, arg: object, move: bool = False, align: str = "left", font: tuple[str, int, str] = ("Arial", 8, "normal")
478 ) -> None: ...
479 if sys.version_info >= (3, 14):
480 @contextmanager
481 def poly(self) -> Generator[None]: ...
482
483 def begin_poly(self) -> None: ...
484 def end_poly(self) -> None: ...
485 def get_poly(self) -> _PolygonCoords | None: ...
486 def getscreen(self) -> TurtleScreen: ...
487 def getturtle(self) -> Self: ...
488 getpen = getturtle
489 def onclick(self, fun: Callable[[float, float], object], btn: int = 1, add: bool | None = None) -> None: ...
490 def onrelease(self, fun: Callable[[float, float], object], btn: int = 1, add: bool | None = None) -> None: ...
491 def ondrag(self, fun: Callable[[float, float], object], btn: int = 1, add: bool | None = None) -> None: ...
492 def undo(self) -> None: ...
493 turtlesize = shapesize
494
495 class _Screen(TurtleScreen):
496 def __init__(self) -> None: ...
497 # Note int and float are interpreted differently, hence the Union instead of just float
498 def setup(
499 self,
500 width: int | float = 0.5, # noqa: Y041
501 height: int | float = 0.75, # noqa: Y041
502 startx: int | None = None,
503 starty: int | None = None,
504 ) -> None: ...
505 def title(self, titlestring: str) -> None: ...
506 def bye(self) -> None: ...
507 def exitonclick(self) -> None: ...
508
509 class Turtle(RawTurtle):
510 def __init__(self, shape: str = "classic", undobuffersize: int = 1000, visible: bool = True) -> None: ...
511
512 RawPen = RawTurtle
513 Pen = Turtle
514
515 def write_docstringdict(filename: str = "turtle_docstringdict") -> None: ...
516
517 # Functions copied from TurtleScreenBase:
518
519 def mainloop() -> None: ...
520 def textinput(title: str, prompt: str) -> str | None: ...
521 def numinput(
522 title: str, prompt: str, default: float | None = None, minval: float | None = None, maxval: float | None = None
523 ) -> float | None: ...
524
525 # Functions copied from TurtleScreen:
526
527 def clear() -> None: ...
528 @overload
529 def mode(mode: None = None) -> str: ...
530 @overload
531 def mode(mode: Literal["standard", "logo", "world"]) -> None: ...
532 def setworldcoordinates(llx: float, lly: float, urx: float, ury: float) -> None: ...
533 def register_shape(name: str, shape: _PolygonCoords | Shape | None = None) -> None: ...
534 @overload
535 def colormode(cmode: None = None) -> float: ...
536 @overload
537 def colormode(cmode: float) -> None: ...
538 def reset() -> None: ...
539 def turtles() -> list[Turtle]: ...
540 @overload
541 def bgcolor() -> _AnyColor: ...
542 @overload
543 def bgcolor(color: _Color) -> None: ...
544 @overload
545 def bgcolor(r: float, g: float, b: float) -> None: ...
546 @overload
547 def tracer(n: None = None) -> int: ...
548 @overload
549 def tracer(n: int, delay: int | None = None) -> None: ...
550 @overload
551 def delay(delay: None = None) -> int: ...
552 @overload
553 def delay(delay: int) -> None: ...
554
555 if sys.version_info >= (3, 14):
556 @contextmanager
557 def no_animation() -> Generator[None]: ...
558
559 def update() -> None: ...
560 def window_width() -> int: ...
561 def window_height() -> int: ...
562 def getcanvas() -> Canvas: ...
563 def getshapes() -> list[str]: ...
564 def onclick(fun: Callable[[float, float], object], btn: int = 1, add: bool | None = None) -> None: ...
565 def onkey(fun: Callable[[], object], key: str) -> None: ...
566 def listen(xdummy: float | None = None, ydummy: float | None = None) -> None: ...
567 def ontimer(fun: Callable[[], object], t: int = 0) -> None: ...
568 @overload
569 def bgpic(picname: None = None) -> str: ...
570 @overload
571 def bgpic(picname: str) -> None: ...
572 @overload
573 def screensize(canvwidth: None = None, canvheight: None = None, bg: None = None) -> tuple[int, int]: ...
574 @overload
575 def screensize(canvwidth: int, canvheight: int, bg: _Color | None = None) -> None: ...
576
577 if sys.version_info >= (3, 14):
578 def save(filename: StrPath, *, overwrite: bool = False) -> None: ...
579
580 onscreenclick = onclick
581 resetscreen = reset
582 clearscreen = clear
583 addshape = register_shape
584
585 def onkeypress(fun: Callable[[], object], key: str | None = None) -> None: ...
586
587 onkeyrelease = onkey
588
589 # Functions copied from _Screen:
590
591 def setup(width: float = 0.5, height: float = 0.75, startx: int | None = None, starty: int | None = None) -> None: ...
592 def title(titlestring: str) -> None: ...
593 def bye() -> None: ...
594 def exitonclick() -> None: ...
595 def Screen() -> _Screen: ...
596
597 # Functions copied from TNavigator:
598
599 def degrees(fullcircle: float = 360.0) -> None: ...
600 def radians() -> None: ...
601 def forward(distance: float) -> None: ...
602 def back(distance: float) -> None: ...
603 def right(angle: float) -> None: ...
604 def left(angle: float) -> None: ...
605 def pos() -> Vec2D: ...
606 def xcor() -> float: ...
607 def ycor() -> float: ...
608 @overload
609 def goto(x: tuple[float, float], y: None = None) -> None: ...
610 @overload
611 def goto(x: float, y: float) -> None: ...
612 def home() -> None: ...
613 def setx(x: float) -> None: ...
614 def sety(y: float) -> None: ...
615 @overload
616 def distance(x: TNavigator | tuple[float, float], y: None = None) -> float: ...
617 @overload
618 def distance(x: float, y: float) -> float: ...
619 @overload
620 def towards(x: TNavigator | tuple[float, float], y: None = None) -> float: ...
621 @overload
622 def towards(x: float, y: float) -> float: ...
623 def heading() -> float: ...
624 def setheading(to_angle: float) -> None: ...
625 def circle(radius: float, extent: float | None = None, steps: int | None = None) -> None: ...
626
627 fd = forward
628 bk = back
629 backward = back
630 rt = right
631 lt = left
632 position = pos
633 setpos = goto
634 setposition = goto
635 seth = setheading
636
637 # Functions copied from TPen:
638 @overload
639 def resizemode(rmode: None = None) -> str: ...
640 @overload
641 def resizemode(rmode: Literal["auto", "user", "noresize"]) -> None: ...
642 @overload
643 def pensize(width: None = None) -> int: ...
644 @overload
645 def pensize(width: int) -> None: ...
646 def penup() -> None: ...
647 def pendown() -> None: ...
648 def isdown() -> bool: ...
649 @overload
650 def speed(speed: None = None) -> int: ...
651 @overload
652 def speed(speed: _Speed) -> None: ...
653 @overload
654 def pencolor() -> _AnyColor: ...
655 @overload
656 def pencolor(color: _Color) -> None: ...
657 @overload
658 def pencolor(r: float, g: float, b: float) -> None: ...
659 @overload
660 def fillcolor() -> _AnyColor: ...
661 @overload
662 def fillcolor(color: _Color) -> None: ...
663 @overload
664 def fillcolor(r: float, g: float, b: float) -> None: ...
665 @overload
666 def color() -> tuple[_AnyColor, _AnyColor]: ...
667 @overload
668 def color(color: _Color) -> None: ...
669 @overload
670 def color(r: float, g: float, b: float) -> None: ...
671 @overload
672 def color(color1: _Color, color2: _Color) -> None: ...
673 def showturtle() -> None: ...
674 def hideturtle() -> None: ...
675 def isvisible() -> bool: ...
676
677 # Note: signatures 1 and 2 overlap unsafely when no arguments are provided
678 @overload
679 def pen() -> _PenState: ...
680 @overload
681 def pen(
682 pen: _PenState | None = None,
683 *,
684 shown: bool = ...,
685 pendown: bool = ...,
686 pencolor: _Color = ...,
687 fillcolor: _Color = ...,
688 pensize: int = ...,
689 speed: int = ...,
690 resizemode: Literal["auto", "user", "noresize"] = ...,
691 stretchfactor: tuple[float, float] = ...,
692 outline: int = ...,
693 tilt: float = ...,
694 ) -> None: ...
695
696 width = pensize
697 up = penup
698 pu = penup
699 pd = pendown
700 down = pendown
701 st = showturtle
702 ht = hideturtle
703
704 # Functions copied from RawTurtle:
705
706 def setundobuffer(size: int | None) -> None: ...
707 def undobufferentries() -> int: ...
708 @overload
709 def shape(name: None = None) -> str: ...
710 @overload
711 def shape(name: str) -> None: ...
712
713 if sys.version_info >= (3, 12):
714 def teleport(x: float | None = None, y: float | None = None, *, fill_gap: bool = False) -> None: ...
715
716 # Unsafely overlaps when no arguments are provided
717 @overload
718 def shapesize() -> tuple[float, float, float]: ...
719 @overload
720 def shapesize(stretch_wid: float | None = None, stretch_len: float | None = None, outline: float | None = None) -> None: ...
721 @overload
722 def shearfactor(shear: None = None) -> float: ...
723 @overload
724 def shearfactor(shear: float) -> None: ...
725
726 # Unsafely overlaps when no arguments are provided
727 @overload
728 def shapetransform() -> tuple[float, float, float, float]: ...
729 @overload
730 def shapetransform(
731 t11: float | None = None, t12: float | None = None, t21: float | None = None, t22: float | None = None
732 ) -> None: ...
733 def get_shapepoly() -> _PolygonCoords | None: ...
734
735 if sys.version_info < (3, 13):
736 @deprecated("Deprecated since Python 3.1; removed in Python 3.13. Use `tiltangle()` instead.")
737 def settiltangle(angle: float) -> None: ...
738
739 @overload
740 def tiltangle(angle: None = None) -> float: ...
741 @overload
742 def tiltangle(angle: float) -> None: ...
743 def tilt(angle: float) -> None: ...
744
745 # Can return either 'int' or Tuple[int, ...] based on if the stamp is
746 # a compound stamp or not. So, as per the "no Union return" policy,
747 # we return Any.
748 def stamp() -> Any: ...
749 def clearstamp(stampid: int | tuple[int, ...]) -> None: ...
750 def clearstamps(n: int | None = None) -> None: ...
751 def filling() -> bool: ...
752
753 if sys.version_info >= (3, 14):
754 @contextmanager
755 def fill() -> Generator[None]: ...
756
757 def begin_fill() -> None: ...
758 def end_fill() -> None: ...
759 @overload
760 def dot(size: int | _Color | None = None) -> None: ...
761 @overload
762 def dot(size: int | None, color: _Color, /) -> None: ...
763 @overload
764 def dot(size: int | None, r: float, g: float, b: float, /) -> None: ...
765 def write(arg: object, move: bool = False, align: str = "left", font: tuple[str, int, str] = ("Arial", 8, "normal")) -> None: ...
766
767 if sys.version_info >= (3, 14):
768 @contextmanager
769 def poly() -> Generator[None]: ...
770
771 def begin_poly() -> None: ...
772 def end_poly() -> None: ...
773 def get_poly() -> _PolygonCoords | None: ...
774 def getscreen() -> TurtleScreen: ...
775 def getturtle() -> Turtle: ...
776
777 getpen = getturtle
778
779 def onrelease(fun: Callable[[float, float], object], btn: int = 1, add: bool | None = None) -> None: ...
780 def ondrag(fun: Callable[[float, float], object], btn: int = 1, add: bool | None = None) -> None: ...
781 def undo() -> None: ...
782
783 turtlesize = shapesize
784
785 # Functions copied from RawTurtle with a few tweaks:
786
787 def clone() -> Turtle: ...
788
789 # Extra functions present only in the global scope:
790
791 done = mainloop