Skip to content

Commit

Permalink
Add types to some tkinter.Text methods. (#10946)
Browse files Browse the repository at this point in the history
Co-authored-by: Akuli <[email protected]>
  • Loading branch information
TeamSpen210 and Akuli authored Oct 31, 2023
1 parent a5d6163 commit 3c872ca
Showing 1 changed file with 72 additions and 10 deletions.
82 changes: 72 additions & 10 deletions stdlib/tkinter/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3064,11 +3064,40 @@ class Text(Widget, XView, YView):
def edit_separator(self) -> None: ... # actually returns empty string
def edit_undo(self) -> None: ... # actually returns empty string
def get(self, index1: _TextIndex, index2: _TextIndex | None = None) -> str: ...
# TODO: image_* methods
def image_cget(self, index, option): ...
def image_configure(self, index, cnf: Incomplete | None = None, **kw): ...
def image_create(self, index, cnf={}, **kw): ...
def image_names(self): ...
@overload
def image_cget(self, index: _TextIndex, option: Literal["image", "name"]) -> str: ...
@overload
def image_cget(self, index: _TextIndex, option: Literal["padx", "pady"]) -> int: ...
@overload
def image_cget(self, index: _TextIndex, option: Literal["align"]) -> Literal["baseline", "bottom", "center", "top"]: ...
@overload
def image_cget(self, index: _TextIndex, option: str) -> Any: ...
@overload
def image_configure(self, index: _TextIndex, cnf: str) -> tuple[str, str, str, str, str | int]: ...
@overload
def image_configure(
self,
index: _TextIndex,
cnf: dict[str, Any] | None = {},
*,
align: Literal["baseline", "bottom", "center", "top"] = ...,
image: _ImageSpec = ...,
name: str = ...,
padx: _ScreenUnits = ...,
pady: _ScreenUnits = ...,
) -> dict[str, tuple[str, str, str, str, str | int]] | None: ...
def image_create(
self,
index: _TextIndex,
cnf: dict[str, Any] | None = {},
*,
align: Literal["baseline", "bottom", "center", "top"] = ...,
image: _ImageSpec = ...,
name: str = ...,
padx: _ScreenUnits = ...,
pady: _ScreenUnits = ...,
) -> str: ...
def image_names(self) -> tuple[str, ...]: ...
def index(self, index: _TextIndex) -> str: ...
def insert(self, index: _TextIndex, chars: str, *args: str | list[str] | tuple[str, ...]) -> None: ...
@overload
Expand Down Expand Up @@ -3166,12 +3195,45 @@ class Text(Widget, XView, YView):
def tag_ranges(self, tagName: str) -> tuple[_tkinter.Tcl_Obj, ...]: ...
# tag_remove and tag_delete are different
def tag_remove(self, tagName: str, index1: _TextIndex, index2: _TextIndex | None = None) -> None: ...
# TODO: window_* methods
def window_cget(self, index, option): ...
def window_configure(self, index, cnf: Incomplete | None = None, **kw): ...
@overload
def window_cget(self, index: _TextIndex, option: Literal["padx", "pady"]) -> int: ...
@overload
def window_cget(self, index: _TextIndex, option: Literal["stretch"]) -> bool: ... # actually returns Literal[0, 1]
@overload
def window_cget(self, index: _TextIndex, option: Literal["align"]) -> Literal["baseline", "bottom", "center", "top"]: ...
@overload # window is set to a widget, but read as the string name.
def window_cget(self, index: _TextIndex, option: Literal["create", "window"]) -> str: ...
@overload
def window_cget(self, index: _TextIndex, option: str) -> Any: ...
@overload
def window_configure(self, index: _TextIndex, cnf: str) -> tuple[str, str, str, str, str | int]: ...
@overload
def window_configure(
self,
index: _TextIndex,
cnf: dict[str, Any] | None = None,
*,
align: Literal["baseline", "bottom", "center", "top"] = ...,
create: str = ...,
padx: _ScreenUnits = ...,
pady: _ScreenUnits = ...,
stretch: bool | Literal[0, 1] = ...,
window: Misc | str = ...,
) -> dict[str, tuple[str, str, str, str, str | int]] | None: ...
window_config = window_configure
def window_create(self, index, cnf={}, **kw) -> None: ...
def window_names(self): ...
def window_create(
self,
index: _TextIndex,
cnf: dict[str, Any] | None = {},
*,
align: Literal["baseline", "bottom", "center", "top"] = ...,
create: str = ...,
padx: _ScreenUnits = ...,
pady: _ScreenUnits = ...,
stretch: bool | Literal[0, 1] = ...,
window: Misc | str = ...,
) -> None: ...
def window_names(self) -> tuple[str, ...]: ...
def yview_pickplace(self, *what): ... # deprecated

class _setit:
Expand Down

0 comments on commit 3c872ca

Please sign in to comment.