Skip to content

More complete type stubs for tkinter Canvas methods. #5188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Apr 22, 2021
181 changes: 167 additions & 14 deletions stdlib/tkinter/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ _TkinterSequence2D = Union[List[List[_T]], List[Tuple[_T, ...]], Tuple[List[_T],
_Anchor = Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"] # manual page: Tk_GetAnchor
_Bitmap = str # manual page: Tk_GetBitmap
_ButtonCommand = Union[str, Callable[[], Any]] # return value is returned from Button.invoke()
_CanvasItemId = int # handles for items created on a canvas - can be passed to Canvas.delete()
_Color = str # typically '#rrggbb', '#rgb' or color names.
_Compound = Literal["top", "left", "center", "right", "bottom", "none"] # -compound in manual page named 'options'
_Cursor = Union[str, Tuple[str], Tuple[str, str], Tuple[str, str, str], Tuple[str, str, str, str]] # manual page: Tk_GetCursor
Expand Down Expand Up @@ -1112,26 +1113,178 @@ class Canvas(Widget, XView, YView):
def canvasx(self, screenx, gridspacing: Optional[Any] = ...): ...
def canvasy(self, screeny, gridspacing: Optional[Any] = ...): ...
def coords(self, *args): ...
def create_arc(self, *args, **kw): ...
def create_bitmap(self, *args, **kw): ...
def create_image(self, *args, **kw): ...
def create_line(self, *args, **kw): ...
def create_oval(self, *args, **kw): ...
def create_polygon(self, *args, **kw): ...
def create_rectangle(self, *args, **kw): ...
def create_text(self, *args, **kw): ...
def create_window(self, *args, **kw): ...
def create_arc(self, *args, **kw) -> _CanvasItemId: ...
def create_bitmap(self, *args, **kw) -> _CanvasItemId: ...
def create_image(self, *args, **kw) -> _CanvasItemId: ...
def create_line(
self,
__x0: float,
__y0: float,
__x1: float,
__y1: float,
*,
activedash: _Color = ...,
activefill: _Color = ...,
activestipple: str = ...,
activewidth: _ScreenUnits = ...,
arrow: Literal["first", "last", "both"] = ...,
arrowshape: Tuple[float, float, float] = ...,
capstyle: Literal["round", "projecting", "butt"] = ...,
dash: Union[Tuple[float], Tuple[float, float], Tuple[float, float, float, float]] = ...,
dashoffset: _ScreenUnits = ...,
disableddash: _Color = ...,
disabledfill: _Color = ...,
disabledstipple: _Bitmap = ...,
disabledwidth: _ScreenUnits = ...,
fill: _Color = ...,
joinstyle: Literal["round", "bevel", "miter"] = ...,
offset: _ScreenUnits = ...,
smooth: bool = ...,
splinesteps: float = ...,
state: Literal["normal", "active", "disabled"] = ...,
stipple: _Bitmap = ...,
tags: Union[str, Tuple[str, ...]] = ...,
width: _ScreenUnits = ...,
) -> _CanvasItemId: ...
def create_oval(
self,
__x0: float,
__y0: float,
__x1: float,
__y1: float,
*,
activedash: _Color = ...,
activefill: _Color = ...,
activeoutline: _Color = ...,
activeoutlinestipple: _Color = ...,
activestipple: str = ...,
activewidth: _ScreenUnits = ...,
dash: Union[Tuple[float], Tuple[float, float], Tuple[float, float, float, float]] = ...,
dashoffset: _ScreenUnits = ...,
disableddash: _Color = ...,
disabledfill: _Color = ...,
disabledoutline: _Color = ...,
disabledoutlinestipple: _Color = ...,
disabledstipple: _Bitmap = ...,
disabledwidth: _ScreenUnits = ...,
fill: _Color = ...,
offset: _ScreenUnits = ...,
outline: _Color = ...,
outlineoffset: _ScreenUnits = ...,
outlinestipple: _Bitmap = ...,
state: Literal["normal", "active", "disabled"] = ...,
stipple: _Bitmap = ...,
tags: Union[str, Tuple[str, ...]] = ...,
width: _ScreenUnits = ...,
) -> _CanvasItemId: ...
def create_polygon(
self,
__x0: float,
__y0: float,
__x1: float,
__y1: float,
*xy_pairs: float,
activedash: _Color = ...,
activefill: _Color = ...,
activeoutline: _Color = ...,
activeoutlinestipple: _Color = ...,
activestipple: str = ...,
activewidth: _ScreenUnits = ...,
dash: Union[Tuple[float], Tuple[float, float], Tuple[float, float, float, float]] = ...,
dashoffset: _ScreenUnits = ...,
disableddash: _Color = ...,
disabledfill: _Color = ...,
disabledoutline: _Color = ...,
disabledoutlinestipple: _Color = ...,
disabledstipple: _Bitmap = ...,
disabledwidth: _ScreenUnits = ...,
fill: _Color = ...,
joinstyle: Literal["round", "bevel", "miter"] = ...,
offset: _ScreenUnits = ...,
outline: _Color = ...,
outlineoffset: _ScreenUnits = ...,
outlinestipple: _Bitmap = ...,
smooth: bool = ...,
splinesteps: float = ...,
state: Literal["normal", "active", "disabled"] = ...,
stipple: _Bitmap = ...,
tags: Union[str, Tuple[str, ...]] = ...,
width: _ScreenUnits = ...,
) -> _CanvasItemId: ...
def create_rectangle(
self,
__x0: float,
__y0: float,
__x1: float,
__y1: float,
*,
activedash: _Color = ...,
activefill: _Color = ...,
activeoutline: _Color = ...,
activeoutlinestipple: _Color = ...,
activestipple: str = ...,
activewidth: _ScreenUnits = ...,
dash: Union[Tuple[float], Tuple[float, float], Tuple[float, float, float, float]] = ...,
dashoffset: _ScreenUnits = ...,
disableddash: _Color = ...,
disabledfill: _Color = ...,
disabledoutline: _Color = ...,
disabledoutlinestipple: _Color = ...,
disabledstipple: _Bitmap = ...,
disabledwidth: _ScreenUnits = ...,
fill: _Color = ...,
offset: _ScreenUnits = ...,
outline: _Color = ...,
outlineoffset: _ScreenUnits = ...,
outlinestipple: _Bitmap = ...,
state: Literal["normal", "active", "disabled"] = ...,
stipple: _Bitmap = ...,
tags: Union[str, Tuple[str, ...]] = ...,
width: _ScreenUnits = ...,
) -> _CanvasItemId: ...
def create_text(
self,
__x: float,
__y: float,
*,
activefill: _Color = ...,
activestipple: str = ...,
anchor: _Anchor = ...,
disabledfill: _Color = ...,
disabledstipple: _Bitmap = ...,
fill: _Color = ...,
font: _FontDescription = ...,
justify: Literal["left", "center", "right"] = ...,
offset: _ScreenUnits = ...,
state: Literal["normal", "active", "disabled"] = ...,
stipple: _Bitmap = ...,
tags: Union[str, Tuple[str, ...]] = ...,
text: str = ...,
width: _ScreenUnits = ...,
) -> _CanvasItemId: ...
def create_window(
self,
__x: float,
__y: float,
*,
anchor: _Anchor = ...,
height: _ScreenUnits = ...,
state: Literal["normal", "active", "disabled"] = ...,
tags: Union[str, Tuple[str, ...]] = ...,
width: _ScreenUnits = ...,
window: Widget = ...,
) -> _CanvasItemId: ...
def dchars(self, *args): ...
def delete(self, *args): ...
def delete(self, *tagsOrCanvasIds: Union[str, _CanvasItemId]) -> None: ...
def dtag(self, *args): ...
def find(self, *args): ...
def find_above(self, tagOrId): ...
def find_above(self, tagOrId: Union[str, _CanvasItemId]): ...
def find_all(self): ...
def find_below(self, tagOrId): ...
def find_below(self, tagOrId: Union[str, _CanvasItemId]): ...
def find_closest(self, x, y, halo: Optional[Any] = ..., start: Optional[Any] = ...): ...
def find_enclosed(self, x1, y1, x2, y2): ...
def find_overlapping(self, x1, y1, x2, y2): ...
def find_withtag(self, tagOrId): ...
def find_withtag(self, tagOrId: Union[str, _CanvasItemId]): ...
def focus(self, *args): ...
def gettags(self, *args): ...
def icursor(self, *args): ...
Expand All @@ -1144,7 +1297,7 @@ class Canvas(Widget, XView, YView):
lower: Any
def move(self, *args): ...
if sys.version_info >= (3, 8):
def moveto(self, tagOrId: Union[int, str], x: str = ..., y: str = ...) -> None: ...
def moveto(self, tagOrId: Union[str, _CanvasItemId], x: str = ..., y: str = ...) -> None: ...
def postscript(self, cnf=..., **kw): ...
def tag_raise(self, *args): ...
lift: Any
Expand Down