diff --git a/stdlib/3/tkinter/__init__.pyi b/stdlib/3/tkinter/__init__.pyi index 31ddf1ab1..61ce9a146 100644 --- a/stdlib/3/tkinter/__init__.pyi +++ b/stdlib/3/tkinter/__init__.pyi @@ -550,7 +550,7 @@ class Tk(Misc, Wm): ) -> None: ... @overload def configure( - self, + self: Union[Tk, Toplevel], cnf: Optional[Dict[str, Any]] = ..., *, background: _Color = ..., diff --git a/stdlib/3/tkinter/ttk.pyi b/stdlib/3/tkinter/ttk.pyi index 564ddae3a..1535c2452 100644 --- a/stdlib/3/tkinter/ttk.pyi +++ b/stdlib/3/tkinter/ttk.pyi @@ -234,7 +234,31 @@ class Entry(Widget, tkinter.Entry): ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload def configure(self, cnf: _EntryOptionName) -> Tuple[str, str, str, Any, Any]: ... - config = configure # type: ignore + # config must be copy/pasted, otherwise ttk.Entry().config is mypy error (don't know why) + @overload # type: ignore + def config( + self, + cnf: Optional[Dict[str, Any]] = ..., + *, + background: tkinter._Color = ..., + cursor: tkinter._Cursor = ..., + exportselection: bool = ..., + font: _FontDescription = ..., + foreground: tkinter._Color = ..., + invalidcommand: tkinter._EntryValidateCommand = ..., + justify: Literal["left", "center", "right"] = ..., + show: str = ..., + state: Literal["normal", "disabled", "readonly"] = ..., + style: str = ..., + takefocus: tkinter._TakeFocusValue = ..., + textvariable: tkinter.Variable = ..., + validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., + validatecommand: tkinter._EntryValidateCommand = ..., + width: int = ..., + xscrollcommand: tkinter._XYScrollCommand = ..., + ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + @overload + def config(self, cnf: _EntryOptionName) -> Tuple[str, str, str, Any, Any]: ... def cget(self, key: _EntryOptionName) -> Any: ... # type: ignore def bbox(self, index): ... def identify(self, x, y): ... @@ -316,7 +340,34 @@ class Combobox(Entry): ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload def configure(self, cnf: _ComboboxOptionName) -> Tuple[str, str, str, Any, Any]: ... - config = configure # type: ignore + # config must be copy/pasted, otherwise ttk.Combobox().config is mypy error (don't know why) + @overload # type: ignore + def config( + self, + cnf: Optional[Dict[str, Any]] = ..., + *, + background: tkinter._Color = ..., + cursor: tkinter._Cursor = ..., + exportselection: bool = ..., + font: _FontDescription = ..., + foreground: tkinter._Color = ..., + height: int = ..., + invalidcommand: tkinter._EntryValidateCommand = ..., + justify: Literal["left", "center", "right"] = ..., + postcommand: Union[Callable[[], None], str] = ..., + show: Any = ..., + state: Literal["normal", "readonly", "disabled"] = ..., + style: str = ..., + takefocus: tkinter._TakeFocusValue = ..., + textvariable: tkinter.Variable = ..., + validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., + validatecommand: tkinter._EntryValidateCommand = ..., + values: tkinter._TkinterSequence[str] = ..., + width: int = ..., + xscrollcommand: tkinter._XYScrollCommand = ..., + ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + @overload + def config(self, cnf: _ComboboxOptionName) -> Tuple[str, str, str, Any, Any]: ... def cget(self, key: _ComboboxOptionName) -> Any: ... # type: ignore def current(self, newindex: Optional[Any] = ...): ... def set(self, value): ... @@ -638,7 +689,20 @@ class Panedwindow(Widget, tkinter.PanedWindow): ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload def configure(self, cnf: _PanedwindowOptionName) -> Tuple[str, str, str, Any, Any]: ... - config = configure # type: ignore + # config must be copy/pasted, otherwise ttk.Panedwindow().config is mypy error (don't know why) + @overload # type: ignore + def config( + self, + cnf: Optional[Dict[str, Any]] = ..., + *, + cursor: tkinter._Cursor = ..., + height: int = ..., + style: str = ..., + takefocus: tkinter._TakeFocusValue = ..., + width: int = ..., + ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + @overload + def config(self, cnf: _PanedwindowOptionName) -> Tuple[str, str, str, Any, Any]: ... def cget(self, key: _PanedwindowOptionName) -> Any: ... # type: ignore forget: Any def insert(self, pos, child, **kw): ... @@ -798,7 +862,26 @@ class Scale(Widget, tkinter.Scale): ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload def configure(self, cnf: _ScaleOptionName) -> Tuple[str, str, str, Any, Any]: ... - config = configure # type: ignore + # config must be copy/pasted, otherwise ttk.Scale().config is mypy error (don't know why) + @overload # type: ignore + def config( + self, + cnf: Optional[Dict[str, Any]] = ..., + *, + command: Union[str, Callable[[str], None]] = ..., + cursor: tkinter._Cursor = ..., + from_: float = ..., + length: tkinter._ScreenUnits = ..., + orient: Literal["horizontal", "vertical"] = ..., + state: Any = ..., + style: str = ..., + takefocus: tkinter._TakeFocusValue = ..., + to: float = ..., + value: float = ..., + variable: tkinter.DoubleVar = ..., + ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + @overload + def config(self, cnf: _ScaleOptionName) -> Tuple[str, str, str, Any, Any]: ... def cget(self, key: _ScaleOptionName) -> Any: ... # type: ignore def get(self, x: Optional[Any] = ..., y: Optional[Any] = ...): ... @@ -829,7 +912,20 @@ class Scrollbar(Widget, tkinter.Scrollbar): ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... @overload def configure(self, cnf: _ScrollbarOptionName) -> Tuple[str, str, str, Any, Any]: ... - config = configure # type: ignore + # config must be copy/pasted, otherwise ttk.Scrollbar().config is mypy error (don't know why) + @overload # type: ignore + def config( + self, + cnf: Optional[Dict[str, Any]] = ..., + *, + command: Union[Callable[..., Optional[Tuple[float, float]]], str] = ..., + cursor: tkinter._Cursor = ..., + orient: Literal["horizontal", "vertical"] = ..., + style: str = ..., + takefocus: tkinter._TakeFocusValue = ..., + ) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ... + @overload + def config(self, cnf: _ScrollbarOptionName) -> Tuple[str, str, str, Any, Any]: ... def cget(self, key: _ScrollbarOptionName) -> Any: ... # type: ignore _SeparatorOptionName = Literal["class", "cursor", "orient", "style", "takefocus"]