get rid of tkinter._TkinterSequence type alias (#6181)

This commit is contained in:
Akuli
2021-10-18 08:22:01 +00:00
committed by GitHub
parent cf78194c76
commit 53087be4eb
4 changed files with 101 additions and 91 deletions

View File

@@ -68,23 +68,20 @@ EXCEPTION = _tkinter.EXCEPTION
# something, then you may actually want Callable[something] | str,
# because it's often possible to specify a string of Tcl code.
#
# - If you think the correct type is Iterable[Foo] or Sequence[Foo], it is
# probably list[Foo] | tuple[Foo, ...], disallowing other sequences such
# as deques:
#
# >>> tkinter.Label(font=('Helvetica', 12, collections.deque(['bold'])))
# Traceback (most recent call last):
# ...
# _tkinter.TclError: unknown font style "deque(['bold'])"
#
# - Some options can be set only in __init__, but all options are available
# when getting their values with configure's return value or cget.
#
# - Asks other tkinter users if you haven't worked much with tkinter.
# _TkinterSequence[T] represents a sequence that tkinter understands. It
# differs from typing.Sequence[T]. For example, collections.deque a valid
# Sequence but not a valid _TkinterSequence:
#
# >>> tkinter.Label(font=('Helvetica', 12, collections.deque(['bold'])))
# Traceback (most recent call last):
# ...
# _tkinter.TclError: unknown font style "deque(['bold'])"
_T = TypeVar("_T")
_TkinterSequence = Union[List[_T], Tuple[_T, ...]]
_TkinterSequence2D = Union[List[List[_T]], List[Tuple[_T, ...]], Tuple[List[_T], ...], Tuple[Tuple[_T, ...], ...]]
# Some widgets have an option named -compound that accepts different values
# than the _Compound defined here. Many other options have similar things.
_Anchor = Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"] # manual page: Tk_GetAnchor
@@ -95,7 +92,7 @@ _Color = str # typically '#rrggbb', '#rgb' or color names.
_Compound = Literal["top", "left", "center", "right", "bottom", "none"] # -compound in manual page named 'options'
_Cursor = Union[str, Tuple[str], Tuple[str, str], Tuple[str, str, str], Tuple[str, str, str, str]] # manual page: Tk_GetCursor
_EntryValidateCommand = Union[
Callable[[], bool], str, _TkinterSequence[str]
Callable[[], bool], str, List[str], Tuple[str, ...]
] # example when it's sequence: entry['invalidcommand'] = [entry.register(print), '%P']
_GridIndex = Union[int, str, Literal["all"]]
_ImageSpec = Union[_Image, str] # str can be from e.g. tkinter.image_names()
@@ -518,7 +515,7 @@ class Wm:
@overload
def wm_colormapwindows(self) -> list[Misc]: ...
@overload
def wm_colormapwindows(self, __wlist: _TkinterSequence[Misc]) -> None: ...
def wm_colormapwindows(self, __wlist: list[Misc] | Tuple[Misc, ...]) -> None: ...
@overload
def wm_colormapwindows(self, __first_wlist_item: Misc, *other_wlist_items: Misc) -> None: ...
colormapwindows = wm_colormapwindows
@@ -1144,7 +1141,7 @@ class Canvas(Widget, XView, YView):
@overload
def coords(self) -> list[float]: ...
@overload
def coords(self, __args: _TkinterSequence[int] | _TkinterSequence[float]) -> None: ...
def coords(self, __args: list[int] | list[float] | Tuple[float, ...]) -> None: ...
@overload
def coords(self, __x1: float, __y1: float, *args: float) -> None: ...
# create_foo() methods accept coords as a list, a tuple, or as separate arguments.
@@ -1160,16 +1157,16 @@ class Canvas(Widget, XView, YView):
__x1: float,
__y1: float,
*,
activedash: str | _TkinterSequence[int] = ...,
activedash: str | list[int] | Tuple[int, ...] = ...,
activefill: _Color = ...,
activestipple: str = ...,
activewidth: _ScreenUnits = ...,
arrow: Literal["first", "last", "both"] = ...,
arrowshape: tuple[float, float, float] = ...,
capstyle: Literal["round", "projecting", "butt"] = ...,
dash: str | _TkinterSequence[int] = ...,
dash: str | list[int] | Tuple[int, ...] = ...,
dashoffset: _ScreenUnits = ...,
disableddash: str | _TkinterSequence[int] = ...,
disableddash: str | list[int] | Tuple[int, ...] = ...,
disabledfill: _Color = ...,
disabledstipple: _Bitmap = ...,
disabledwidth: _ScreenUnits = ...,
@@ -1180,7 +1177,7 @@ class Canvas(Widget, XView, YView):
splinesteps: float = ...,
state: Literal["normal", "active", "disabled"] = ...,
stipple: _Bitmap = ...,
tags: str | _TkinterSequence[str] = ...,
tags: str | list[str] | Tuple[str, ...] = ...,
width: _ScreenUnits = ...,
) -> _CanvasItemId: ...
@overload
@@ -1188,16 +1185,16 @@ class Canvas(Widget, XView, YView):
self,
__coords: tuple[float, float, float, float] | list[int] | list[float],
*,
activedash: str | _TkinterSequence[int] = ...,
activedash: str | list[int] | Tuple[int, ...] = ...,
activefill: _Color = ...,
activestipple: str = ...,
activewidth: _ScreenUnits = ...,
arrow: Literal["first", "last", "both"] = ...,
arrowshape: tuple[float, float, float] = ...,
capstyle: Literal["round", "projecting", "butt"] = ...,
dash: str | _TkinterSequence[int] = ...,
dash: str | list[int] | Tuple[int, ...] = ...,
dashoffset: _ScreenUnits = ...,
disableddash: str | _TkinterSequence[int] = ...,
disableddash: str | list[int] | Tuple[int, ...] = ...,
disabledfill: _Color = ...,
disabledstipple: _Bitmap = ...,
disabledwidth: _ScreenUnits = ...,
@@ -1208,7 +1205,7 @@ class Canvas(Widget, XView, YView):
splinesteps: float = ...,
state: Literal["normal", "active", "disabled"] = ...,
stipple: _Bitmap = ...,
tags: str | _TkinterSequence[str] = ...,
tags: str | list[str] | Tuple[str, ...] = ...,
width: _ScreenUnits = ...,
) -> _CanvasItemId: ...
@overload
@@ -1219,15 +1216,15 @@ class Canvas(Widget, XView, YView):
__x1: float,
__y1: float,
*,
activedash: str | _TkinterSequence[int] = ...,
activedash: str | list[int] | Tuple[int, ...] = ...,
activefill: _Color = ...,
activeoutline: _Color = ...,
activeoutlinestipple: _Color = ...,
activestipple: str = ...,
activewidth: _ScreenUnits = ...,
dash: str | _TkinterSequence[int] = ...,
dash: str | list[int] | Tuple[int, ...] = ...,
dashoffset: _ScreenUnits = ...,
disableddash: str | _TkinterSequence[int] = ...,
disableddash: str | list[int] | Tuple[int, ...] = ...,
disabledfill: _Color = ...,
disabledoutline: _Color = ...,
disabledoutlinestipple: _Color = ...,
@@ -1240,7 +1237,7 @@ class Canvas(Widget, XView, YView):
outlinestipple: _Bitmap = ...,
state: Literal["normal", "active", "disabled"] = ...,
stipple: _Bitmap = ...,
tags: str | _TkinterSequence[str] = ...,
tags: str | list[str] | Tuple[str, ...] = ...,
width: _ScreenUnits = ...,
) -> _CanvasItemId: ...
@overload
@@ -1248,15 +1245,15 @@ class Canvas(Widget, XView, YView):
self,
__coords: tuple[float, float, float, float] | list[int] | list[float],
*,
activedash: str | _TkinterSequence[int] = ...,
activedash: str | list[int] | Tuple[int, ...] = ...,
activefill: _Color = ...,
activeoutline: _Color = ...,
activeoutlinestipple: _Color = ...,
activestipple: str = ...,
activewidth: _ScreenUnits = ...,
dash: str | _TkinterSequence[int] = ...,
dash: str | list[int] | Tuple[int, ...] = ...,
dashoffset: _ScreenUnits = ...,
disableddash: str | _TkinterSequence[int] = ...,
disableddash: str | list[int] | Tuple[int, ...] = ...,
disabledfill: _Color = ...,
disabledoutline: _Color = ...,
disabledoutlinestipple: _Color = ...,
@@ -1269,7 +1266,7 @@ class Canvas(Widget, XView, YView):
outlinestipple: _Bitmap = ...,
state: Literal["normal", "active", "disabled"] = ...,
stipple: _Bitmap = ...,
tags: str | _TkinterSequence[str] = ...,
tags: str | list[str] | Tuple[str, ...] = ...,
width: _ScreenUnits = ...,
) -> _CanvasItemId: ...
@overload
@@ -1280,15 +1277,15 @@ class Canvas(Widget, XView, YView):
__x1: float,
__y1: float,
*xy_pairs: float,
activedash: str | _TkinterSequence[int] = ...,
activedash: str | list[int] | Tuple[int, ...] = ...,
activefill: _Color = ...,
activeoutline: _Color = ...,
activeoutlinestipple: _Color = ...,
activestipple: str = ...,
activewidth: _ScreenUnits = ...,
dash: str | _TkinterSequence[int] = ...,
dash: str | list[int] | Tuple[int, ...] = ...,
dashoffset: _ScreenUnits = ...,
disableddash: str | _TkinterSequence[int] = ...,
disableddash: str | list[int] | Tuple[int, ...] = ...,
disabledfill: _Color = ...,
disabledoutline: _Color = ...,
disabledoutlinestipple: _Color = ...,
@@ -1304,7 +1301,7 @@ class Canvas(Widget, XView, YView):
splinesteps: float = ...,
state: Literal["normal", "active", "disabled"] = ...,
stipple: _Bitmap = ...,
tags: str | _TkinterSequence[str] = ...,
tags: str | list[str] | Tuple[str, ...] = ...,
width: _ScreenUnits = ...,
) -> _CanvasItemId: ...
@overload
@@ -1312,15 +1309,15 @@ class Canvas(Widget, XView, YView):
self,
__coords: Tuple[float, ...] | list[int] | list[float],
*,
activedash: str | _TkinterSequence[int] = ...,
activedash: str | list[int] | Tuple[int, ...] = ...,
activefill: _Color = ...,
activeoutline: _Color = ...,
activeoutlinestipple: _Color = ...,
activestipple: str = ...,
activewidth: _ScreenUnits = ...,
dash: str | _TkinterSequence[int] = ...,
dash: str | list[int] | Tuple[int, ...] = ...,
dashoffset: _ScreenUnits = ...,
disableddash: str | _TkinterSequence[int] = ...,
disableddash: str | list[int] | Tuple[int, ...] = ...,
disabledfill: _Color = ...,
disabledoutline: _Color = ...,
disabledoutlinestipple: _Color = ...,
@@ -1336,7 +1333,7 @@ class Canvas(Widget, XView, YView):
splinesteps: float = ...,
state: Literal["normal", "active", "disabled"] = ...,
stipple: _Bitmap = ...,
tags: str | _TkinterSequence[str] = ...,
tags: str | list[str] | Tuple[str, ...] = ...,
width: _ScreenUnits = ...,
) -> _CanvasItemId: ...
@overload
@@ -1347,15 +1344,15 @@ class Canvas(Widget, XView, YView):
__x1: float,
__y1: float,
*,
activedash: str | _TkinterSequence[int] = ...,
activedash: str | list[int] | Tuple[int, ...] = ...,
activefill: _Color = ...,
activeoutline: _Color = ...,
activeoutlinestipple: _Color = ...,
activestipple: str = ...,
activewidth: _ScreenUnits = ...,
dash: str | _TkinterSequence[int] = ...,
dash: str | list[int] | Tuple[int, ...] = ...,
dashoffset: _ScreenUnits = ...,
disableddash: str | _TkinterSequence[int] = ...,
disableddash: str | list[int] | Tuple[int, ...] = ...,
disabledfill: _Color = ...,
disabledoutline: _Color = ...,
disabledoutlinestipple: _Color = ...,
@@ -1368,7 +1365,7 @@ class Canvas(Widget, XView, YView):
outlinestipple: _Bitmap = ...,
state: Literal["normal", "active", "disabled"] = ...,
stipple: _Bitmap = ...,
tags: str | _TkinterSequence[str] = ...,
tags: str | list[str] | Tuple[str, ...] = ...,
width: _ScreenUnits = ...,
) -> _CanvasItemId: ...
@overload
@@ -1376,15 +1373,15 @@ class Canvas(Widget, XView, YView):
self,
__coords: tuple[float, float, float, float] | list[int] | list[float],
*,
activedash: str | _TkinterSequence[int] = ...,
activedash: str | list[int] | Tuple[int, ...] = ...,
activefill: _Color = ...,
activeoutline: _Color = ...,
activeoutlinestipple: _Color = ...,
activestipple: str = ...,
activewidth: _ScreenUnits = ...,
dash: str | _TkinterSequence[int] = ...,
dash: str | list[int] | Tuple[int, ...] = ...,
dashoffset: _ScreenUnits = ...,
disableddash: str | _TkinterSequence[int] = ...,
disableddash: str | list[int] | Tuple[int, ...] = ...,
disabledfill: _Color = ...,
disabledoutline: _Color = ...,
disabledoutlinestipple: _Color = ...,
@@ -1397,7 +1394,7 @@ class Canvas(Widget, XView, YView):
outlinestipple: _Bitmap = ...,
state: Literal["normal", "active", "disabled"] = ...,
stipple: _Bitmap = ...,
tags: str | _TkinterSequence[str] = ...,
tags: str | list[str] | Tuple[str, ...] = ...,
width: _ScreenUnits = ...,
) -> _CanvasItemId: ...
@overload
@@ -1417,7 +1414,7 @@ class Canvas(Widget, XView, YView):
offset: _ScreenUnits = ...,
state: Literal["normal", "active", "disabled"] = ...,
stipple: _Bitmap = ...,
tags: str | _TkinterSequence[str] = ...,
tags: str | list[str] | Tuple[str, ...] = ...,
text: float | str = ...,
width: _ScreenUnits = ...,
) -> _CanvasItemId: ...
@@ -1437,7 +1434,7 @@ class Canvas(Widget, XView, YView):
offset: _ScreenUnits = ...,
state: Literal["normal", "active", "disabled"] = ...,
stipple: _Bitmap = ...,
tags: str | _TkinterSequence[str] = ...,
tags: str | list[str] | Tuple[str, ...] = ...,
text: float | str = ...,
width: _ScreenUnits = ...,
) -> _CanvasItemId: ...
@@ -1450,7 +1447,7 @@ class Canvas(Widget, XView, YView):
anchor: _Anchor = ...,
height: _ScreenUnits = ...,
state: Literal["normal", "active", "disabled"] = ...,
tags: str | _TkinterSequence[str] = ...,
tags: str | list[str] | Tuple[str, ...] = ...,
width: _ScreenUnits = ...,
window: Widget = ...,
) -> _CanvasItemId: ...
@@ -1462,7 +1459,7 @@ class Canvas(Widget, XView, YView):
anchor: _Anchor = ...,
height: _ScreenUnits = ...,
state: Literal["normal", "active", "disabled"] = ...,
tags: str | _TkinterSequence[str] = ...,
tags: str | list[str] | Tuple[str, ...] = ...,
width: _ScreenUnits = ...,
window: Widget = ...,
) -> _CanvasItemId: ...
@@ -2848,7 +2845,7 @@ class Text(Widget, XView, YView):
def image_create(self, index, cnf=..., **kw): ...
def image_names(self): ...
def index(self, index: _TextIndex) -> str: ...
def insert(self, index: _TextIndex, chars: str, *args: str | _TkinterSequence[str]) -> None: ...
def insert(self, index: _TextIndex, chars: str, *args: str | list[str] | Tuple[str, ...]) -> None: ...
@overload
def mark_gravity(self, markName: str, direction: None = ...) -> Literal["left", "right"]: ...
@overload
@@ -2861,7 +2858,7 @@ class Text(Widget, XView, YView):
# **kw of peer_create is same as the kwargs of Text.__init__
def peer_create(self, newPathName: str | Text, cnf: dict[str, Any] = ..., **kw: Any) -> None: ...
def peer_names(self) -> Tuple[_tkinter.Tcl_Obj, ...]: ...
def replace(self, index1: _TextIndex, index2: _TextIndex, chars: str, *args: str | _TkinterSequence[str]) -> None: ...
def replace(self, index1: _TextIndex, index2: _TextIndex, chars: str, *args: str | list[str] | Tuple[str, ...]) -> None: ...
def scan_mark(self, x: int, y: int) -> None: ...
def scan_dragto(self, x: int, y: int) -> None: ...
def search(
@@ -3017,7 +3014,19 @@ class PhotoImage(Image):
def zoom(self, x: int, y: int | Literal[""] = ...) -> PhotoImage: ...
def subsample(self, x: int, y: int | Literal[""] = ...) -> PhotoImage: ...
def get(self, x: int, y: int) -> tuple[int, int, int]: ...
def put(self, data: str | _TkinterSequence[str] | _TkinterSequence2D[_Color], to: tuple[int, int] | None = ...) -> None: ...
def put(
self,
data: (
str
| list[str]
| list[list[_Color]]
| list[Tuple[_Color, ...]]
| Tuple[str, ...]
| Tuple[list[_Color], ...]
| Tuple[Tuple[_Color, ...], ...]
),
to: tuple[int, int] | None = ...,
) -> None: ...
def write(self, filename: StrOrBytesPath, format: str | None = ..., from_coords: tuple[int, int] | None = ...) -> None: ...
if sys.version_info >= (3, 8):
def transparency_get(self, x: int, y: int) -> bool: ...
@@ -3057,8 +3066,8 @@ class Spinbox(Widget, XView):
buttoncursor: _Cursor = ...,
buttondownrelief: _Relief = ...,
buttonuprelief: _Relief = ...,
# percent substitutions don't seem to be supported, it's similar to Entry's validion stuff
command: Callable[[], Any] | str | _TkinterSequence[str] = ...,
# percent substitutions don't seem to be supported, it's similar to Entry's validation stuff
command: Callable[[], Any] | str | list[str] | Tuple[str, ...] = ...,
cursor: _Cursor = ...,
disabledbackground: _Color = ...,
disabledforeground: _Color = ...,
@@ -3095,7 +3104,7 @@ class Spinbox(Widget, XView):
validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ...,
validatecommand: _EntryValidateCommand = ...,
vcmd: _EntryValidateCommand = ...,
values: _TkinterSequence[str] = ...,
values: list[str] | Tuple[str, ...] = ...,
width: int = ...,
wrap: bool = ...,
xscrollcommand: _XYScrollCommand = ...,
@@ -3115,7 +3124,7 @@ class Spinbox(Widget, XView):
buttoncursor: _Cursor = ...,
buttondownrelief: _Relief = ...,
buttonuprelief: _Relief = ...,
command: Callable[[], Any] | str | _TkinterSequence[str] = ...,
command: Callable[[], Any] | str | list[str] | Tuple[str, ...] = ...,
cursor: _Cursor = ...,
disabledbackground: _Color = ...,
disabledforeground: _Color = ...,
@@ -3151,7 +3160,7 @@ class Spinbox(Widget, XView):
validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ...,
validatecommand: _EntryValidateCommand = ...,
vcmd: _EntryValidateCommand = ...,
values: _TkinterSequence[str] = ...,
values: list[str] | Tuple[str, ...] = ...,
width: int = ...,
wrap: bool = ...,
xscrollcommand: _XYScrollCommand = ...,

View File

@@ -1,5 +1,5 @@
from _typeshed import StrOrBytesPath
from tkinter import Button, Entry, Frame, Listbox, Misc, Scrollbar, StringVar, Toplevel, _TkinterSequence, commondialog
from tkinter import Button, Entry, Frame, Listbox, Misc, Scrollbar, StringVar, Toplevel, commondialog
from typing import IO, Any, ClassVar, Iterable, Tuple
from typing_extensions import Literal
@@ -64,7 +64,7 @@ def asksaveasfilename(
*,
confirmoverwrite: bool | None = ...,
defaultextension: str | None = ...,
filetypes: Iterable[tuple[str, str] | tuple[str, _TkinterSequence[str]]] | None = ...,
filetypes: Iterable[tuple[str, str | list[str] | Tuple[str, ...]]] | None = ...,
initialdir: StrOrBytesPath | None = ...,
initialfile: StrOrBytesPath | None = ...,
parent: Misc | None = ...,
@@ -74,7 +74,7 @@ def asksaveasfilename(
def askopenfilename(
*,
defaultextension: str | None = ...,
filetypes: Iterable[tuple[str, str] | tuple[str, _TkinterSequence[str]]] | None = ...,
filetypes: Iterable[tuple[str, str | list[str] | Tuple[str, ...]]] | None = ...,
initialdir: StrOrBytesPath | None = ...,
initialfile: StrOrBytesPath | None = ...,
parent: Misc | None = ...,
@@ -84,7 +84,7 @@ def askopenfilename(
def askopenfilenames(
*,
defaultextension: str | None = ...,
filetypes: Iterable[tuple[str, str] | tuple[str, _TkinterSequence[str]]] | None = ...,
filetypes: Iterable[tuple[str, str | list[str] | Tuple[str, ...]]] | None = ...,
initialdir: StrOrBytesPath | None = ...,
initialfile: StrOrBytesPath | None = ...,
parent: Misc | None = ...,
@@ -101,7 +101,7 @@ def asksaveasfile(
*,
confirmoverwrite: bool | None = ...,
defaultextension: str | None = ...,
filetypes: Iterable[tuple[str, str] | tuple[str, _TkinterSequence[str]]] | None = ...,
filetypes: Iterable[tuple[str, str | list[str] | Tuple[str, ...]]] | None = ...,
initialdir: StrOrBytesPath | None = ...,
initialfile: StrOrBytesPath | None = ...,
parent: Misc | None = ...,
@@ -112,7 +112,7 @@ def askopenfile(
mode: str = ...,
*,
defaultextension: str | None = ...,
filetypes: Iterable[tuple[str, str] | tuple[str, _TkinterSequence[str]]] | None = ...,
filetypes: Iterable[tuple[str, str | list[str] | Tuple[str, ...]]] | None = ...,
initialdir: StrOrBytesPath | None = ...,
initialfile: StrOrBytesPath | None = ...,
parent: Misc | None = ...,
@@ -123,7 +123,7 @@ def askopenfiles(
mode: str = ...,
*,
defaultextension: str | None = ...,
filetypes: Iterable[tuple[str, str] | tuple[str, _TkinterSequence[str]]] | None = ...,
filetypes: Iterable[tuple[str, str | list[str] | Tuple[str, ...]]] | None = ...,
initialdir: StrOrBytesPath | None = ...,
initialfile: StrOrBytesPath | None = ...,
parent: Misc | None = ...,

View File

@@ -1,7 +1,7 @@
import _tkinter
import sys
import tkinter
from typing import Any, Tuple, Union, overload
from typing import Any, List, Tuple, Union, overload
from typing_extensions import Literal, TypedDict
NORMAL: Literal["normal"]
@@ -15,7 +15,8 @@ _FontDescription = Union[
# A font object constructed in Python
Font,
# ("Helvetica", 12, BOLD)
tkinter._TkinterSequence[Any],
List[Any],
Tuple[Any, ...],
# A font object constructed in Tcl
_tkinter.Tcl_Obj,
]

View File

@@ -234,7 +234,7 @@ class Combobox(Entry):
textvariable: tkinter.Variable = ...,
validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., # undocumented
validatecommand: tkinter._EntryValidateCommand = ..., # undocumented
values: tkinter._TkinterSequence[str] = ...,
values: list[str] | Tuple[str, ...] = ...,
width: int = ...,
xscrollcommand: tkinter._XYScrollCommand = ..., # undocumented
) -> None: ...
@@ -259,7 +259,7 @@ class Combobox(Entry):
textvariable: tkinter.Variable = ...,
validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ...,
validatecommand: tkinter._EntryValidateCommand = ...,
values: tkinter._TkinterSequence[str] = ...,
values: list[str] | Tuple[str, ...] = ...,
width: int = ...,
xscrollcommand: tkinter._XYScrollCommand = ...,
) -> dict[str, tuple[str, str, str, Any, Any]] | None: ...
@@ -287,7 +287,7 @@ class Combobox(Entry):
textvariable: tkinter.Variable = ...,
validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ...,
validatecommand: tkinter._EntryValidateCommand = ...,
values: tkinter._TkinterSequence[str] = ...,
values: list[str] | Tuple[str, ...] = ...,
width: int = ...,
xscrollcommand: tkinter._XYScrollCommand = ...,
) -> dict[str, tuple[str, str, str, Any, Any]] | None: ...
@@ -828,7 +828,7 @@ if sys.version_info >= (3, 7):
*,
background: tkinter._Color = ..., # undocumented
class_: str = ...,
command: Callable[[], Any] | str | tkinter._TkinterSequence[str] = ...,
command: Callable[[], Any] | str | list[str] | Tuple[str, ...] = ...,
cursor: tkinter._Cursor = ...,
exportselection: bool = ..., # undocumented
font: _FontDescription = ..., # undocumented
@@ -847,7 +847,7 @@ if sys.version_info >= (3, 7):
to: float = ...,
validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ...,
validatecommand: tkinter._EntryValidateCommand = ...,
values: tkinter._TkinterSequence[str] = ...,
values: list[str] | Tuple[str, ...] = ...,
width: int = ..., # undocumented
wrap: bool = ...,
xscrollcommand: tkinter._XYScrollCommand = ...,
@@ -858,7 +858,7 @@ if sys.version_info >= (3, 7):
cnf: dict[str, Any] | None = ...,
*,
background: tkinter._Color = ...,
command: Callable[[], Any] | str | tkinter._TkinterSequence[str] = ...,
command: Callable[[], Any] | str | list[str] | Tuple[str, ...] = ...,
cursor: tkinter._Cursor = ...,
exportselection: bool = ...,
font: _FontDescription = ...,
@@ -876,7 +876,7 @@ if sys.version_info >= (3, 7):
to: float = ...,
validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ...,
validatecommand: tkinter._EntryValidateCommand = ...,
values: tkinter._TkinterSequence[str] = ...,
values: list[str] | Tuple[str, ...] = ...,
width: int = ...,
wrap: bool = ...,
xscrollcommand: tkinter._XYScrollCommand = ...,
@@ -922,18 +922,18 @@ class Treeview(Widget, tkinter.XView, tkinter.YView):
master: tkinter.Misc | None = ...,
*,
class_: str = ...,
columns: str | tkinter._TkinterSequence[str] = ...,
columns: str | list[str] | Tuple[str, ...] = ...,
cursor: tkinter._Cursor = ...,
displaycolumns: str | tkinter._TkinterSequence[str] | tkinter._TkinterSequence[int] | Literal["#all"] = ...,
displaycolumns: str | list[str] | Tuple[str, ...] | list[int] | Tuple[int, ...] | Literal["#all"] = ...,
height: int = ...,
name: str = ...,
padding: tkinter._Padding = ...,
selectmode: Literal["extended", "browse", "none"] = ...,
# _TkinterSequences of Literal don't actually work, using str instead.
# list/tuple of Literal don't actually work in mypy
#
# 'tree headings' is same as ['tree', 'headings'], and I wouldn't be
# surprised if someone was using it.
show: Literal["tree", "headings", "tree headings", ""] | tkinter._TkinterSequence[str] = ...,
# surprised if someone is using it.
show: Literal["tree", "headings", "tree headings", ""] | list[str] | Tuple[str, ...] = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
xscrollcommand: tkinter._XYScrollCommand = ...,
@@ -944,13 +944,13 @@ class Treeview(Widget, tkinter.XView, tkinter.YView):
self,
cnf: dict[str, Any] | None = ...,
*,
columns: str | tkinter._TkinterSequence[str] = ...,
columns: str | list[str] | Tuple[str, ...] = ...,
cursor: tkinter._Cursor = ...,
displaycolumns: str | tkinter._TkinterSequence[str] | tkinter._TkinterSequence[int] | Literal["#all"] = ...,
displaycolumns: str | list[str] | Tuple[str, ...] | list[int] | Tuple[int, ...] | Literal["#all"] = ...,
height: int = ...,
padding: tkinter._Padding = ...,
selectmode: Literal["extended", "browse", "none"] = ...,
show: Literal["tree", "headings", "tree headings", ""] | tkinter._TkinterSequence[str] = ...,
show: Literal["tree", "headings", "tree headings", ""] | list[str] | Tuple[str, ...] = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
xscrollcommand: tkinter._XYScrollCommand = ...,
@@ -1027,9 +1027,9 @@ class Treeview(Widget, tkinter.XView, tkinter.YView):
id: str = ..., # same as iid
text: str = ...,
image: tkinter._ImageSpec = ...,
values: tkinter._TkinterSequence[Any] = ...,
values: list[Any] | Tuple[Any, ...] = ...,
open: bool = ...,
tags: str | tkinter._TkinterSequence[str] = ...,
tags: str | list[str] | Tuple[str, ...] = ...,
) -> str: ...
@overload
def item(self, item: str, option: Literal["text"]) -> str: ...
@@ -1051,9 +1051,9 @@ class Treeview(Widget, tkinter.XView, tkinter.YView):
*,
text: str = ...,
image: tkinter._ImageSpec = ...,
values: tkinter._TkinterSequence[Any] | Literal[""] = ...,
values: list[Any] | Tuple[Any, ...] | Literal[""] = ...,
open: bool = ...,
tags: str | tkinter._TkinterSequence[str] = ...,
tags: str | list[str] | Tuple[str, ...] = ...,
) -> _TreeviewItemDict | None: ...
def move(self, item: str, parent: str, index: int) -> None: ...
reattach = move
@@ -1065,10 +1065,10 @@ class Treeview(Widget, tkinter.XView, tkinter.YView):
def selection(self) -> Tuple[str, ...]: ...
else:
def selection(self, selop: Any | None = ..., items: Any | None = ...) -> Tuple[str, ...]: ...
def selection_set(self, items: str | tkinter._TkinterSequence[str]) -> None: ...
def selection_add(self, items: str | tkinter._TkinterSequence[str]) -> None: ...
def selection_remove(self, items: str | tkinter._TkinterSequence[str]) -> None: ...
def selection_toggle(self, items: str | tkinter._TkinterSequence[str]) -> None: ...
def selection_set(self, items: str | list[str] | Tuple[str, ...]) -> None: ...
def selection_add(self, items: str | list[str] | Tuple[str, ...]) -> None: ...
def selection_remove(self, items: str | list[str] | Tuple[str, ...]) -> None: ...
def selection_toggle(self, items: str | list[str] | Tuple[str, ...]) -> None: ...
@overload
def set(self, item: str, column: None = ..., value: None = ...) -> dict[str, Any]: ...
@overload