[tkinter] Remove a few type aliases (#14742)

This commit is contained in:
Semyon Moroz
2025-09-23 23:59:57 +04:00
committed by GitHub
parent b0d926ee22
commit 2cc9c1667d
3 changed files with 321 additions and 332 deletions
File diff suppressed because it is too large Load Diff
+109 -109
View File
@@ -46,14 +46,14 @@ _Padding: TypeAlias = (
| tuple[tkinter._ScreenUnits, tkinter._ScreenUnits, tkinter._ScreenUnits, tkinter._ScreenUnits]
)
# from ttk_widget (aka ttk::widget) manual page, differs from tkinter._Compound
_TtkCompound: TypeAlias = Literal["", "text", "image", tkinter._Compound]
# from ttk_widget (aka ttk::widget) manual page, differs from compound
_TtkCompound: TypeAlias = Literal["", "text", "image", "top", "left", "center", "right", "bottom", "none"]
# Last item (option value to apply) varies between different options so use Any.
# It could also be any iterable with items matching the tuple, but that case
# hasn't been added here for consistency with _Padding above.
_Statespec: TypeAlias = tuple[Unpack[tuple[str, ...]], Any]
_ImageStatespec: TypeAlias = tuple[Unpack[tuple[str, ...]], tkinter._ImageSpec]
_ImageStatespec: TypeAlias = tuple[Unpack[tuple[str, ...]], tkinter._Image | str]
_VsapiStatespec: TypeAlias = tuple[Unpack[tuple[str, ...]], int]
class _Layout(TypedDict, total=False):
@@ -76,7 +76,7 @@ class _ElementCreateImageKwargs(TypedDict, total=False):
_ElementCreateArgsCrossPlatform: TypeAlias = (
# Could be any sequence here but types are not homogenous so just type it as tuple
tuple[Literal["image"], tkinter._ImageSpec, Unpack[tuple[_ImageStatespec, ...]], _ElementCreateImageKwargs]
tuple[Literal["image"], tkinter._Image | str, Unpack[tuple[_ImageStatespec, ...]], _ElementCreateImageKwargs]
| tuple[Literal["from"], str, str]
| tuple[Literal["from"], str] # (fromelement is optional)
)
@@ -139,7 +139,7 @@ class Style:
self,
elementname: str,
etype: Literal["image"],
default_image: tkinter._ImageSpec,
default_image: tkinter._Image | str,
/,
*imagespec: _ImageStatespec,
border: _Padding = ...,
@@ -214,16 +214,16 @@ class Button(Widget):
master: tkinter.Misc | None = None,
*,
class_: str = "",
command: tkinter._ButtonCommand = "",
command: str | Callable[[], Any] = "",
compound: _TtkCompound = "",
cursor: tkinter._Cursor = "",
default: Literal["normal", "active", "disabled"] = "normal",
image: tkinter._ImageSpec = "",
image: tkinter._Image | str = "",
name: str = ...,
padding=..., # undocumented
state: str = "normal",
style: str = "",
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
text: float | str = "",
textvariable: tkinter.Variable = ...,
underline: int = -1,
@@ -234,15 +234,15 @@ class Button(Widget):
self,
cnf: dict[str, Any] | None = None,
*,
command: tkinter._ButtonCommand = ...,
command: str | Callable[[], Any] = ...,
compound: _TtkCompound = ...,
cursor: tkinter._Cursor = ...,
default: Literal["normal", "active", "disabled"] = ...,
image: tkinter._ImageSpec = ...,
image: tkinter._Image | str = ...,
padding=...,
state: str = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
text: float | str = ...,
textvariable: tkinter.Variable = ...,
underline: int = ...,
@@ -259,17 +259,17 @@ class Checkbutton(Widget):
master: tkinter.Misc | None = None,
*,
class_: str = "",
command: tkinter._ButtonCommand = "",
command: str | Callable[[], Any] = "",
compound: _TtkCompound = "",
cursor: tkinter._Cursor = "",
image: tkinter._ImageSpec = "",
image: tkinter._Image | str = "",
name: str = ...,
offvalue: Any = 0,
onvalue: Any = 1,
padding=..., # undocumented
state: str = "normal",
style: str = "",
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
text: float | str = "",
textvariable: tkinter.Variable = ...,
underline: int = -1,
@@ -284,16 +284,16 @@ class Checkbutton(Widget):
self,
cnf: dict[str, Any] | None = None,
*,
command: tkinter._ButtonCommand = ...,
command: str | Callable[[], Any] = ...,
compound: _TtkCompound = ...,
cursor: tkinter._Cursor = ...,
image: tkinter._ImageSpec = ...,
image: tkinter._Image | str = ...,
offvalue: Any = ...,
onvalue: Any = ...,
padding=...,
state: str = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
text: float | str = ...,
textvariable: tkinter.Variable = ...,
underline: int = ...,
@@ -317,18 +317,18 @@ class Entry(Widget, tkinter.Entry):
exportselection: bool = True,
font: _FontDescription = "TkTextFont",
foreground: str = "",
invalidcommand: tkinter._EntryValidateCommand = "",
invalidcommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = "",
justify: Literal["left", "center", "right"] = "left",
name: str = ...,
show: str = "",
state: str = "normal",
style: str = "",
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
textvariable: tkinter.Variable = ...,
validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = "none",
validatecommand: tkinter._EntryValidateCommand = "",
validatecommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = "",
width: int = 20,
xscrollcommand: tkinter._XYScrollCommand = "",
xscrollcommand: str | Callable[[float, float], object] = "",
) -> None: ...
@overload # type: ignore[override]
def configure(
@@ -340,17 +340,17 @@ class Entry(Widget, tkinter.Entry):
exportselection: bool = ...,
font: _FontDescription = ...,
foreground: str = ...,
invalidcommand: tkinter._EntryValidateCommand = ...,
invalidcommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = ...,
justify: Literal["left", "center", "right"] = ...,
show: str = ...,
state: str = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
textvariable: tkinter.Variable = ...,
validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ...,
validatecommand: tkinter._EntryValidateCommand = ...,
validatecommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = ...,
width: int = ...,
xscrollcommand: tkinter._XYScrollCommand = ...,
xscrollcommand: str | Callable[[float, float], object] = ...,
) -> dict[str, tuple[str, str, str, Any, Any]] | None: ...
@overload
def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ...
@@ -365,17 +365,17 @@ class Entry(Widget, tkinter.Entry):
exportselection: bool = ...,
font: _FontDescription = ...,
foreground: str = ...,
invalidcommand: tkinter._EntryValidateCommand = ...,
invalidcommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = ...,
justify: Literal["left", "center", "right"] = ...,
show: str = ...,
state: str = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
textvariable: tkinter.Variable = ...,
validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ...,
validatecommand: tkinter._EntryValidateCommand = ...,
validatecommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = ...,
width: int = ...,
xscrollcommand: tkinter._XYScrollCommand = ...,
xscrollcommand: str | Callable[[float, float], object] = ...,
) -> dict[str, tuple[str, str, str, Any, Any]] | None: ...
@overload
def config(self, cnf: str) -> tuple[str, str, str, Any, Any]: ...
@@ -395,20 +395,20 @@ class Combobox(Entry):
font: _FontDescription = ..., # undocumented
foreground: str = ..., # undocumented
height: int = 10,
invalidcommand: tkinter._EntryValidateCommand = ..., # undocumented
invalidcommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = ..., # undocumented
justify: Literal["left", "center", "right"] = "left",
name: str = ...,
postcommand: Callable[[], object] | str = "",
show=..., # undocumented
state: str = "normal",
style: str = "",
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
textvariable: tkinter.Variable = ...,
validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., # undocumented
validatecommand: tkinter._EntryValidateCommand = ..., # undocumented
validatecommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = ..., # undocumented
values: list[str] | tuple[str, ...] = ...,
width: int = 20,
xscrollcommand: tkinter._XYScrollCommand = ..., # undocumented
xscrollcommand: str | Callable[[float, float], object] = ..., # undocumented
) -> None: ...
@overload # type: ignore[override]
def configure(
@@ -421,19 +421,19 @@ class Combobox(Entry):
font: _FontDescription = ...,
foreground: str = ...,
height: int = ...,
invalidcommand: tkinter._EntryValidateCommand = ...,
invalidcommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = ...,
justify: Literal["left", "center", "right"] = ...,
postcommand: Callable[[], object] | str = ...,
show=...,
state: str = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
textvariable: tkinter.Variable = ...,
validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ...,
validatecommand: tkinter._EntryValidateCommand = ...,
validatecommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = ...,
values: list[str] | tuple[str, ...] = ...,
width: int = ...,
xscrollcommand: tkinter._XYScrollCommand = ...,
xscrollcommand: str | Callable[[float, float], object] = ...,
) -> dict[str, tuple[str, str, str, Any, Any]] | None: ...
@overload
def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ...
@@ -449,19 +449,19 @@ class Combobox(Entry):
font: _FontDescription = ...,
foreground: str = ...,
height: int = ...,
invalidcommand: tkinter._EntryValidateCommand = ...,
invalidcommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = ...,
justify: Literal["left", "center", "right"] = ...,
postcommand: Callable[[], object] | str = ...,
show=...,
state: str = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
textvariable: tkinter.Variable = ...,
validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ...,
validatecommand: tkinter._EntryValidateCommand = ...,
validatecommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = ...,
values: list[str] | tuple[str, ...] = ...,
width: int = ...,
xscrollcommand: tkinter._XYScrollCommand = ...,
xscrollcommand: str | Callable[[float, float], object] = ...,
) -> dict[str, tuple[str, str, str, Any, Any]] | None: ...
@overload
def config(self, cnf: str) -> tuple[str, str, str, Any, Any]: ...
@@ -482,9 +482,9 @@ class Frame(Widget):
height: tkinter._ScreenUnits = 0,
name: str = ...,
padding: _Padding = ...,
relief: tkinter._Relief = ...,
relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ...,
style: str = "",
takefocus: tkinter._TakeFocusValue = "",
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = "",
width: tkinter._ScreenUnits = 0,
) -> None: ...
@overload
@@ -497,9 +497,9 @@ class Frame(Widget):
cursor: tkinter._Cursor = ...,
height: tkinter._ScreenUnits = ...,
padding: _Padding = ...,
relief: tkinter._Relief = ...,
relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
width: tkinter._ScreenUnits = ...,
) -> dict[str, tuple[str, str, str, Any, Any]] | None: ...
@overload
@@ -511,7 +511,7 @@ class Label(Widget):
self,
master: tkinter.Misc | None = None,
*,
anchor: tkinter._Anchor = ...,
anchor: Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"] = ...,
background: str = "",
border: tkinter._ScreenUnits = ..., # alias for borderwidth
borderwidth: tkinter._ScreenUnits = ..., # undocumented
@@ -520,14 +520,14 @@ class Label(Widget):
cursor: tkinter._Cursor = "",
font: _FontDescription = ...,
foreground: str = "",
image: tkinter._ImageSpec = "",
image: tkinter._Image | str = "",
justify: Literal["left", "center", "right"] = ...,
name: str = ...,
padding: _Padding = ...,
relief: tkinter._Relief = ...,
relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ...,
state: str = "normal",
style: str = "",
takefocus: tkinter._TakeFocusValue = "",
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = "",
text: float | str = "",
textvariable: tkinter.Variable = ...,
underline: int = -1,
@@ -539,7 +539,7 @@ class Label(Widget):
self,
cnf: dict[str, Any] | None = None,
*,
anchor: tkinter._Anchor = ...,
anchor: Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"] = ...,
background: str = ...,
border: tkinter._ScreenUnits = ...,
borderwidth: tkinter._ScreenUnits = ...,
@@ -547,13 +547,13 @@ class Label(Widget):
cursor: tkinter._Cursor = ...,
font: _FontDescription = ...,
foreground: str = ...,
image: tkinter._ImageSpec = ...,
image: tkinter._Image | str = ...,
justify: Literal["left", "center", "right"] = ...,
padding: _Padding = ...,
relief: tkinter._Relief = ...,
relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ...,
state: str = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
text: float | str = ...,
textvariable: tkinter.Variable = ...,
underline: int = ...,
@@ -578,9 +578,9 @@ class Labelframe(Widget):
labelwidget: tkinter.Misc = ...,
name: str = ...,
padding: _Padding = ...,
relief: tkinter._Relief = ..., # undocumented
relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ..., # undocumented
style: str = "",
takefocus: tkinter._TakeFocusValue = "",
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = "",
text: float | str = "",
underline: int = -1,
width: tkinter._ScreenUnits = 0,
@@ -597,9 +597,9 @@ class Labelframe(Widget):
labelanchor: Literal["nw", "n", "ne", "en", "e", "es", "se", "s", "sw", "ws", "w", "wn"] = ...,
labelwidget: tkinter.Misc = ...,
padding: _Padding = ...,
relief: tkinter._Relief = ...,
relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
text: float | str = ...,
underline: int = ...,
width: tkinter._ScreenUnits = ...,
@@ -619,13 +619,13 @@ class Menubutton(Widget):
compound: _TtkCompound = "",
cursor: tkinter._Cursor = "",
direction: Literal["above", "below", "left", "right", "flush"] = "below",
image: tkinter._ImageSpec = "",
image: tkinter._Image | str = "",
menu: tkinter.Menu = ...,
name: str = ...,
padding=..., # undocumented
state: str = "normal",
style: str = "",
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
text: float | str = "",
textvariable: tkinter.Variable = ...,
underline: int = -1,
@@ -639,12 +639,12 @@ class Menubutton(Widget):
compound: _TtkCompound = ...,
cursor: tkinter._Cursor = ...,
direction: Literal["above", "below", "left", "right", "flush"] = ...,
image: tkinter._ImageSpec = ...,
image: tkinter._Image | str = ...,
menu: tkinter.Menu = ...,
padding=...,
state: str = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
text: float | str = ...,
textvariable: tkinter.Variable = ...,
underline: int = ...,
@@ -665,7 +665,7 @@ class Notebook(Widget):
name: str = ...,
padding: _Padding = ...,
style: str = "",
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
width: int = 0,
) -> None: ...
@overload
@@ -677,7 +677,7 @@ class Notebook(Widget):
height: int = ...,
padding: _Padding = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
width: int = ...,
) -> dict[str, tuple[str, str, str, Any, Any]] | None: ...
@overload
@@ -694,7 +694,7 @@ class Notebook(Widget):
# `image` is a sequence of an image name, followed by zero or more
# (sequences of one or more state names followed by an image name)
image=...,
compound: tkinter._Compound = ...,
compound: Literal["top", "left", "center", "right", "bottom", "none"] = ...,
underline: int = ...,
) -> None: ...
def forget(self, tab_id) -> None: ... # type: ignore[override]
@@ -719,7 +719,7 @@ class Panedwindow(Widget, tkinter.PanedWindow):
name: str = ...,
orient: Literal["vertical", "horizontal"] = "vertical", # can't be changed with configure()
style: str = "",
takefocus: tkinter._TakeFocusValue = "",
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = "",
width: int = 0,
) -> None: ...
def add(self, child: tkinter.Widget, *, weight: int = ..., **kw) -> None: ...
@@ -731,7 +731,7 @@ class Panedwindow(Widget, tkinter.PanedWindow):
cursor: tkinter._Cursor = ...,
height: int = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
width: int = ...,
) -> dict[str, tuple[str, str, str, Any, Any]] | None: ...
@overload
@@ -745,7 +745,7 @@ class Panedwindow(Widget, tkinter.PanedWindow):
cursor: tkinter._Cursor = ...,
height: int = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
width: int = ...,
) -> dict[str, tuple[str, str, str, Any, Any]] | None: ...
@overload
@@ -771,7 +771,7 @@ class Progressbar(Widget):
orient: Literal["horizontal", "vertical"] = "horizontal",
phase: int = 0, # docs say read-only but assigning int to this works
style: str = "",
takefocus: tkinter._TakeFocusValue = "",
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = "",
value: float = 0.0,
variable: tkinter.IntVar | tkinter.DoubleVar = ...,
) -> None: ...
@@ -787,7 +787,7 @@ class Progressbar(Widget):
orient: Literal["horizontal", "vertical"] = ...,
phase: int = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
value: float = ...,
variable: tkinter.IntVar | tkinter.DoubleVar = ...,
) -> dict[str, tuple[str, str, str, Any, Any]] | None: ...
@@ -804,15 +804,15 @@ class Radiobutton(Widget):
master: tkinter.Misc | None = None,
*,
class_: str = "",
command: tkinter._ButtonCommand = "",
command: str | Callable[[], Any] = "",
compound: _TtkCompound = "",
cursor: tkinter._Cursor = "",
image: tkinter._ImageSpec = "",
image: tkinter._Image | str = "",
name: str = ...,
padding=..., # undocumented
state: str = "normal",
style: str = "",
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
text: float | str = "",
textvariable: tkinter.Variable = ...,
underline: int = -1,
@@ -825,14 +825,14 @@ class Radiobutton(Widget):
self,
cnf: dict[str, Any] | None = None,
*,
command: tkinter._ButtonCommand = ...,
command: str | Callable[[], Any] = ...,
compound: _TtkCompound = ...,
cursor: tkinter._Cursor = ...,
image: tkinter._ImageSpec = ...,
image: tkinter._Image | str = ...,
padding=...,
state: str = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
text: float | str = ...,
textvariable: tkinter.Variable = ...,
underline: int = ...,
@@ -860,7 +860,7 @@ class Scale(Widget, tkinter.Scale): # type: ignore[misc]
orient: Literal["horizontal", "vertical"] = "horizontal",
state: str = ..., # undocumented
style: str = "",
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
to: float = 1.0,
value: float = 0,
variable: tkinter.IntVar | tkinter.DoubleVar = ...,
@@ -877,7 +877,7 @@ class Scale(Widget, tkinter.Scale): # type: ignore[misc]
orient: Literal["horizontal", "vertical"] = ...,
state: str = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
to: float = ...,
value: float = ...,
variable: tkinter.IntVar | tkinter.DoubleVar = ...,
@@ -897,7 +897,7 @@ class Scale(Widget, tkinter.Scale): # type: ignore[misc]
orient: Literal["horizontal", "vertical"] = ...,
state: str = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
to: float = ...,
value: float = ...,
variable: tkinter.IntVar | tkinter.DoubleVar = ...,
@@ -918,7 +918,7 @@ class Scrollbar(Widget, tkinter.Scrollbar): # type: ignore[misc]
name: str = ...,
orient: Literal["horizontal", "vertical"] = "vertical",
style: str = "",
takefocus: tkinter._TakeFocusValue = "",
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = "",
) -> None: ...
@overload # type: ignore[override]
def configure(
@@ -929,7 +929,7 @@ class Scrollbar(Widget, tkinter.Scrollbar): # type: ignore[misc]
cursor: tkinter._Cursor = ...,
orient: Literal["horizontal", "vertical"] = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
) -> dict[str, tuple[str, str, str, Any, Any]] | None: ...
@overload
def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ...
@@ -943,7 +943,7 @@ class Scrollbar(Widget, tkinter.Scrollbar): # type: ignore[misc]
cursor: tkinter._Cursor = ...,
orient: Literal["horizontal", "vertical"] = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
) -> dict[str, tuple[str, str, str, Any, Any]] | None: ...
@overload
def config(self, cnf: str) -> tuple[str, str, str, Any, Any]: ...
@@ -958,7 +958,7 @@ class Separator(Widget):
name: str = ...,
orient: Literal["horizontal", "vertical"] = "horizontal",
style: str = "",
takefocus: tkinter._TakeFocusValue = "",
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = "",
) -> None: ...
@overload
def configure(
@@ -968,7 +968,7 @@ class Separator(Widget):
cursor: tkinter._Cursor = ...,
orient: Literal["horizontal", "vertical"] = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
) -> dict[str, tuple[str, str, str, Any, Any]] | None: ...
@overload
def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ...
@@ -983,7 +983,7 @@ class Sizegrip(Widget):
cursor: tkinter._Cursor = ...,
name: str = ...,
style: str = "",
takefocus: tkinter._TakeFocusValue = "",
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = "",
) -> None: ...
@overload
def configure(
@@ -992,7 +992,7 @@ class Sizegrip(Widget):
*,
cursor: tkinter._Cursor = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
) -> dict[str, tuple[str, str, str, Any, Any]] | None: ...
@overload
def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ...
@@ -1013,21 +1013,21 @@ class Spinbox(Entry):
format: str = "",
from_: float = 0,
increment: float = 1,
invalidcommand: tkinter._EntryValidateCommand = ..., # undocumented
invalidcommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = ..., # undocumented
justify: Literal["left", "center", "right"] = ..., # undocumented
name: str = ...,
show=..., # undocumented
state: str = "normal",
style: str = "",
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
textvariable: tkinter.Variable = ..., # undocumented
to: float = 0,
validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = "none",
validatecommand: tkinter._EntryValidateCommand = "",
validatecommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = "",
values: list[str] | tuple[str, ...] = ...,
width: int = ..., # undocumented
wrap: bool = False,
xscrollcommand: tkinter._XYScrollCommand = "",
xscrollcommand: str | Callable[[float, float], object] = "",
) -> None: ...
@overload # type: ignore[override]
def configure(
@@ -1043,20 +1043,20 @@ class Spinbox(Entry):
format: str = ...,
from_: float = ...,
increment: float = ...,
invalidcommand: tkinter._EntryValidateCommand = ...,
invalidcommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = ...,
justify: Literal["left", "center", "right"] = ...,
show=...,
state: str = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
textvariable: tkinter.Variable = ...,
to: float = ...,
validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ...,
validatecommand: tkinter._EntryValidateCommand = ...,
validatecommand: str | list[str] | tuple[str, ...] | Callable[[], bool] = ...,
values: list[str] | tuple[str, ...] = ...,
width: int = ...,
wrap: bool = ...,
xscrollcommand: tkinter._XYScrollCommand = ...,
xscrollcommand: str | Callable[[float, float], object] = ...,
) -> dict[str, tuple[str, str, str, Any, Any]] | None: ...
@overload
def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ...
@@ -1083,7 +1083,7 @@ class _TreeviewTagDict(TypedDict):
class _TreeviewHeaderDict(TypedDict):
text: str
image: list[str] | Literal[""]
anchor: tkinter._Anchor
anchor: Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"]
command: str
state: str # Doesn't seem to appear anywhere else than in these dicts
@@ -1092,7 +1092,7 @@ class _TreeviewColumnDict(TypedDict):
width: int
minwidth: int
stretch: bool # actually 0 or 1
anchor: tkinter._Anchor
anchor: Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"]
id: str
class Treeview(Widget, tkinter.XView, tkinter.YView):
@@ -1114,9 +1114,9 @@ class Treeview(Widget, tkinter.XView, tkinter.YView):
# surprised if someone is using it.
show: Literal["tree", "headings", "tree headings", ""] | list[str] | tuple[str, ...] = ("tree", "headings"),
style: str = "",
takefocus: tkinter._TakeFocusValue = ...,
xscrollcommand: tkinter._XYScrollCommand = "",
yscrollcommand: tkinter._XYScrollCommand = "",
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
xscrollcommand: str | Callable[[float, float], object] = "",
yscrollcommand: str | Callable[[float, float], object] = "",
) -> None: ...
@overload
def configure(
@@ -1131,9 +1131,9 @@ class Treeview(Widget, tkinter.XView, tkinter.YView):
selectmode: Literal["extended", "browse", "none"] = ...,
show: Literal["tree", "headings", "tree headings", ""] | list[str] | tuple[str, ...] = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
xscrollcommand: tkinter._XYScrollCommand = ...,
yscrollcommand: tkinter._XYScrollCommand = ...,
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ...,
xscrollcommand: str | Callable[[float, float], object] = ...,
yscrollcommand: str | Callable[[float, float], object] = ...,
) -> dict[str, tuple[str, str, str, Any, Any]] | None: ...
@overload
def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ...
@@ -1160,7 +1160,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView):
width: int = ...,
minwidth: int = ...,
stretch: bool = ...,
anchor: tkinter._Anchor = ...,
anchor: Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"] = ...,
# id is read-only
) -> _TreeviewColumnDict | None: ...
def delete(self, *items: str | int) -> None: ...
@@ -1189,8 +1189,8 @@ class Treeview(Widget, tkinter.XView, tkinter.YView):
option: None = None,
*,
text: str = ...,
image: tkinter._ImageSpec = ...,
anchor: tkinter._Anchor = ...,
image: tkinter._Image | str = ...,
anchor: Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"] = ...,
command: str | Callable[[], object] = ...,
) -> None: ...
# Internal Method. Leave untyped:
@@ -1208,7 +1208,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView):
*,
id: str | int = ..., # same as iid
text: str = ...,
image: tkinter._ImageSpec = ...,
image: tkinter._Image | str = ...,
values: list[Any] | tuple[Any, ...] = ...,
open: bool = ...,
tags: str | list[str] | tuple[str, ...] = ...,
@@ -1234,7 +1234,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView):
option: None = None,
*,
text: str = ...,
image: tkinter._ImageSpec = ...,
image: tkinter._Image | str = ...,
values: list[Any] | tuple[Any, ...] | Literal[""] = ...,
open: bool = ...,
tags: str | list[str] | tuple[str, ...] = ...,
@@ -1294,7 +1294,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView):
foreground: str = ...,
background: str = ...,
font: _FontDescription = ...,
image: tkinter._ImageSpec = ...,
image: tkinter._Image | str = ...,
) -> _TreeviewTagDict | MaybeNone: ... # can be None but annoying to check
@overload
def tag_has(self, tagname: str, item: None = None) -> tuple[str, ...]: ...
@@ -1321,9 +1321,9 @@ class LabeledScale(Frame):
height: tkinter._ScreenUnits = 0,
name: str = ...,
padding: _Padding = ...,
relief: tkinter._Relief = ...,
relief: Literal["raised", "sunken", "flat", "ridge", "solid", "groove"] = ...,
style: str = "",
takefocus: tkinter._TakeFocusValue = "",
takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = "",
width: tkinter._ScreenUnits = 0,
) -> None: ...
# destroy is overridden, signature does not change