Add many missing tkinter type annotations (#6002)

Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
Co-authored-by: Akuli <akuviljanen17@gmail.com>
This commit is contained in:
Screwtapello
2021-09-12 18:42:12 +10:00
committed by GitHub
parent 8576b344b8
commit 4c6e98ed0c
4 changed files with 92 additions and 33 deletions

View File

@@ -509,7 +509,18 @@ class Notebook(Widget):
@overload
def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ...
config = configure
def add(self, child, **kw): ...
def add(
self,
child: tkinter.Widget,
*,
state: Literal["normal", "disabled", "hidden"] = ...,
sticky: str = ..., # consists of letters 'n', 's', 'w', 'e', no repeats, may be empty
padding: tkinter._Padding = ...,
text: str = ...,
image: Any = ..., # Sequence of an image name, followed by zero or more (sequences of one or more state names followed by an image name)
compound: tkinter._Compound = ...,
underline: int = ...,
) -> None: ...
def forget(self, tab_id): ...
def hide(self, tab_id): ...
def identify(self, x, y): ...
@@ -518,7 +529,7 @@ class Notebook(Widget):
def select(self, tab_id: Any | None = ...): ...
def tab(self, tab_id, option: Any | None = ..., **kw): ...
def tabs(self): ...
def enable_traversal(self): ...
def enable_traversal(self) -> None: ...
class Panedwindow(Widget, tkinter.PanedWindow):
def __init__(
@@ -535,6 +546,7 @@ class Panedwindow(Widget, tkinter.PanedWindow):
takefocus: tkinter._TakeFocusValue = ...,
width: int = ...,
) -> None: ...
def add(self, child: tkinter.Widget, *, weight: int = ..., **kw) -> None: ...
@overload # type: ignore
def configure(
self,
@@ -882,11 +894,11 @@ class _TreeviewItemDict(TypedDict):
tags: list[str]
class _TreeviewTagDict(TypedDict):
text: str
image: Literal[""] | str # not wrapped in list :D
anchor: tkinter._Anchor
background: tkinter._Color
# There is also 'text' and 'anchor', but they don't seem to do anything, using them is likely a bug
foreground: tkinter._Color
background: tkinter._Color
font: _FontDescription
image: Literal[""] | str # not wrapped in list :D
class _TreeviewHeaderDict(TypedDict):
text: str
@@ -997,7 +1009,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView):
*,
text: str = ...,
image: tkinter._ImageSpec = ...,
anochor: tkinter._Anchor = ...,
anchor: tkinter._Anchor = ...,
command: str | Callable[[], Any] = ...,
) -> _TreeviewHeaderDict | None: ...
def identify(self, component, x, y): ...
@@ -1074,27 +1086,23 @@ class Treeview(Widget, tkinter.XView, tkinter.YView):
@overload
def tag_bind(self, tagname: str, *, callback: str) -> None: ...
@overload
def tag_configure(self, tagname: str, option: Literal["text"]) -> str: ...
@overload
def tag_configure(self, tagname: str, option: Literal["image"]) -> str: ...
@overload
def tag_configure(self, tagname: str, option: Literal["anchor"]) -> tkinter._Anchor | Literal[""]: ...
@overload
def tag_configure(self, tagname: str, option: Literal["foreground", "background"]) -> tkinter._Color: ...
@overload
def tag_configure(self, tagname: str, option: str) -> Any: ...
def tag_configure(self, tagname: str, option: Literal["font"]) -> _FontDescription: ...
@overload
def tag_configure(self, tagname: str, option: Literal["image"]) -> str: ...
@overload
def tag_configure(
self,
tagname: str,
option: None = ...,
*,
text: str = ...,
image: tkinter._ImageSpec = ...,
anchor: tkinter._Anchor = ...,
background: tkinter._Color = ...,
# There is also 'text' and 'anchor', but they don't seem to do anything, using them is likely a bug
foreground: tkinter._Color = ...,
) -> _TreeviewTagDict | None: ...
background: tkinter._Color = ...,
font: _FontDescription = ...,
image: tkinter._ImageSpec = ...,
) -> _TreeviewTagDict | Any: ... # can be None but annoying to check
@overload
def tag_has(self, tagname: str, item: None = ...) -> Tuple[str, ...]: ...
@overload