From 5994da3c8f9d3bc641e89080a2311e6a44904c94 Mon Sep 17 00:00:00 2001 From: Akuli Date: Sun, 6 Jun 2021 16:17:21 +0300 Subject: [PATCH] add types to tkinter invoke methods --- stdlib/tkinter/__init__.pyi | 11 ++++++----- stdlib/tkinter/ttk.pyi | 6 +++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index 8d328abae4d5..131895bcf863 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -995,7 +995,7 @@ class Button(Widget): def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure def flash(self): ... - def invoke(self): ... + def invoke(self) -> Any: ... class Canvas(Widget, XView, YView): def __init__( @@ -1417,7 +1417,7 @@ class Checkbutton(Widget): config = configure def deselect(self): ... def flash(self): ... - def invoke(self): ... + def invoke(self) -> Any: ... def select(self): ... def toggle(self): ... @@ -2040,7 +2040,7 @@ class Menu(Widget): def entryconfigure(self, index, cnf: Optional[Any] = ..., **kw): ... entryconfig: Any def index(self, index): ... - def invoke(self, index): ... + def invoke(self, index: _MenuIndex) -> Any: ... def post(self, x, y): ... def type(self, index): ... def unpost(self): ... @@ -2297,7 +2297,7 @@ class Radiobutton(Widget): config = configure def deselect(self): ... def flash(self): ... - def invoke(self): ... + def invoke(self) -> Any: ... def select(self): ... class Scale(Widget): @@ -2969,7 +2969,8 @@ class Spinbox(Widget, XView): def identify(self, x, y): ... def index(self, index): ... def insert(self, index, s): ... - def invoke(self, element): ... + # spinbox.invoke("asdf") gives error mentioning .invoke("none"), but it's not documented + def invoke(self, element: Literal["none", "buttonup", "buttondown"]) -> Literal[""]: ... def scan(self, *args): ... def scan_mark(self, x): ... def scan_dragto(self, x): ... diff --git a/stdlib/tkinter/ttk.pyi b/stdlib/tkinter/ttk.pyi index af3c75142598..f3e109df1cf8 100644 --- a/stdlib/tkinter/ttk.pyi +++ b/stdlib/tkinter/ttk.pyi @@ -76,7 +76,7 @@ class Button(Widget): @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure - def invoke(self): ... + def invoke(self) -> Any: ... class Checkbutton(Widget): def __init__( @@ -128,7 +128,7 @@ class Checkbutton(Widget): @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure - def invoke(self): ... + def invoke(self) -> Any: ... class Entry(Widget, tkinter.Entry): def __init__( @@ -652,7 +652,7 @@ class Radiobutton(Widget): @overload def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ... config = configure - def invoke(self): ... + def invoke(self) -> Any: ... class Scale(Widget, tkinter.Scale): def __init__(