Big diff: Use new "|" union syntax (#5872)

This commit is contained in:
Akuli
2021-08-08 12:05:21 +03:00
committed by GitHub
parent b9adb7a874
commit ee487304d7
578 changed files with 8080 additions and 8966 deletions

View File

@@ -2,11 +2,11 @@ import _tkinter
import sys
import tkinter
from tkinter.font import _FontDescription
from typing import Any, Callable, Dict, Optional, Tuple, Union, overload
from typing import Any, Callable, Dict, Tuple, Union, overload
from typing_extensions import Literal, TypedDict
def tclobjs_to_py(adict): ...
def setup_master(master: Optional[Any] = ...): ...
def setup_master(master: Any | None = ...): ...
# from ttk_widget (aka ttk::widget) manual page, differs from tkinter._Compound
_TtkCompound = Literal["text", "image", tkinter._Compound]
@@ -14,29 +14,29 @@ _TtkCompound = Literal["text", "image", tkinter._Compound]
class Style:
master: Any
tk: _tkinter.TkappType
def __init__(self, master: Optional[Any] = ...): ...
def configure(self, style, query_opt: Optional[Any] = ..., **kw): ...
def map(self, style, query_opt: Optional[Any] = ..., **kw): ...
def lookup(self, style, option, state: Optional[Any] = ..., default: Optional[Any] = ...): ...
def layout(self, style, layoutspec: Optional[Any] = ...): ...
def __init__(self, master: Any | None = ...): ...
def configure(self, style, query_opt: Any | None = ..., **kw): ...
def map(self, style, query_opt: Any | None = ..., **kw): ...
def lookup(self, style, option, state: Any | None = ..., default: Any | None = ...): ...
def layout(self, style, layoutspec: Any | None = ...): ...
def element_create(self, elementname, etype, *args, **kw): ...
def element_names(self): ...
def element_options(self, elementname): ...
def theme_create(self, themename, parent: Optional[Any] = ..., settings: Optional[Any] = ...): ...
def theme_create(self, themename, parent: Any | None = ..., settings: Any | None = ...): ...
def theme_settings(self, themename, settings): ...
def theme_names(self): ...
def theme_use(self, themename: Optional[Any] = ...): ...
def theme_use(self, themename: Any | None = ...): ...
class Widget(tkinter.Widget):
def __init__(self, master: Optional[tkinter.Misc], widgetname, kw: Optional[Any] = ...): ...
def __init__(self, master: tkinter.Misc | None, widgetname, kw: Any | None = ...): ...
def identify(self, x, y): ...
def instate(self, statespec, callback: Optional[Any] = ..., *args, **kw): ...
def state(self, statespec: Optional[Any] = ...): ...
def instate(self, statespec, callback: Any | None = ..., *args, **kw): ...
def state(self, statespec: Any | None = ...): ...
class Button(Widget):
def __init__(
self,
master: Optional[tkinter.Misc] = ...,
master: tkinter.Misc | None = ...,
*,
class_: str = ...,
command: tkinter._ButtonCommand = ...,
@@ -49,15 +49,15 @@ class Button(Widget):
state: str = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
text: Union[float, str] = ...,
text: float | str = ...,
textvariable: tkinter.Variable = ...,
underline: int = ...,
width: Union[int, Literal[""]] = ...,
width: int | Literal[""] = ...,
) -> None: ...
@overload
def configure(
self,
cnf: Optional[Dict[str, Any]] = ...,
cnf: Dict[str, Any] | None = ...,
*,
command: tkinter._ButtonCommand = ...,
compound: _TtkCompound = ...,
@@ -68,11 +68,11 @@ class Button(Widget):
state: str = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
text: Union[float, str] = ...,
text: float | str = ...,
textvariable: tkinter.Variable = ...,
underline: int = ...,
width: Union[int, Literal[""]] = ...,
) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ...
width: int | Literal[""] = ...,
) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ...
@overload
def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ...
config = configure
@@ -81,7 +81,7 @@ class Button(Widget):
class Checkbutton(Widget):
def __init__(
self,
master: Optional[tkinter.Misc] = ...,
master: tkinter.Misc | None = ...,
*,
class_: str = ...,
command: tkinter._ButtonCommand = ...,
@@ -95,19 +95,19 @@ class Checkbutton(Widget):
state: str = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
text: Union[float, str] = ...,
text: float | str = ...,
textvariable: tkinter.Variable = ...,
underline: int = ...,
# Seems like variable can be empty string, but actually setting it to
# empty string segfaults before Tcl 8.6.9. Search for ttk::checkbutton
# here: https://sourceforge.net/projects/tcl/files/Tcl/8.6.9/tcltk-release-notes-8.6.9.txt/view
variable: tkinter.Variable = ...,
width: Union[int, Literal[""]] = ...,
width: int | Literal[""] = ...,
) -> None: ...
@overload
def configure(
self,
cnf: Optional[Dict[str, Any]] = ...,
cnf: Dict[str, Any] | None = ...,
*,
command: tkinter._ButtonCommand = ...,
compound: _TtkCompound = ...,
@@ -119,12 +119,12 @@ class Checkbutton(Widget):
state: str = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
text: Union[float, str] = ...,
text: float | str = ...,
textvariable: tkinter.Variable = ...,
underline: int = ...,
variable: tkinter.Variable = ...,
width: Union[int, Literal[""]] = ...,
) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ...
width: int | Literal[""] = ...,
) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ...
@overload
def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ...
config = configure
@@ -133,8 +133,8 @@ class Checkbutton(Widget):
class Entry(Widget, tkinter.Entry):
def __init__(
self,
master: Optional[tkinter.Misc] = ...,
widget: Optional[str] = ...,
master: tkinter.Misc | None = ...,
widget: str | None = ...,
*,
background: tkinter._Color = ..., # undocumented
class_: str = ...,
@@ -158,7 +158,7 @@ class Entry(Widget, tkinter.Entry):
@overload # type: ignore
def configure(
self,
cnf: Optional[Dict[str, Any]] = ...,
cnf: Dict[str, Any] | None = ...,
*,
background: tkinter._Color = ...,
cursor: tkinter._Cursor = ...,
@@ -176,14 +176,14 @@ class Entry(Widget, tkinter.Entry):
validatecommand: tkinter._EntryValidateCommand = ...,
width: int = ...,
xscrollcommand: tkinter._XYScrollCommand = ...,
) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ...
) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ...
@overload
def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ...
# 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]] = ...,
cnf: Dict[str, Any] | None = ...,
*,
background: tkinter._Color = ...,
cursor: tkinter._Cursor = ...,
@@ -201,7 +201,7 @@ class Entry(Widget, tkinter.Entry):
validatecommand: tkinter._EntryValidateCommand = ...,
width: int = ...,
xscrollcommand: tkinter._XYScrollCommand = ...,
) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ...
) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ...
@overload
def config(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ...
def bbox(self, index): ...
@@ -211,7 +211,7 @@ class Entry(Widget, tkinter.Entry):
class Combobox(Entry):
def __init__(
self,
master: Optional[tkinter.Misc] = ...,
master: tkinter.Misc | None = ...,
*,
background: tkinter._Color = ..., # undocumented
class_: str = ...,
@@ -223,7 +223,7 @@ class Combobox(Entry):
invalidcommand: tkinter._EntryValidateCommand = ..., # undocumented
justify: Literal["left", "center", "right"] = ...,
name: str = ...,
postcommand: Union[Callable[[], Any], str] = ...,
postcommand: Callable[[], Any] | str = ...,
show: Any = ..., # undocumented
state: str = ...,
style: str = ...,
@@ -238,7 +238,7 @@ class Combobox(Entry):
@overload # type: ignore
def configure(
self,
cnf: Optional[Dict[str, Any]] = ...,
cnf: Dict[str, Any] | None = ...,
*,
background: tkinter._Color = ...,
cursor: tkinter._Cursor = ...,
@@ -248,7 +248,7 @@ class Combobox(Entry):
height: int = ...,
invalidcommand: tkinter._EntryValidateCommand = ...,
justify: Literal["left", "center", "right"] = ...,
postcommand: Union[Callable[[], Any], str] = ...,
postcommand: Callable[[], Any] | str = ...,
show: Any = ...,
state: str = ...,
style: str = ...,
@@ -259,14 +259,14 @@ class Combobox(Entry):
values: tkinter._TkinterSequence[str] = ...,
width: int = ...,
xscrollcommand: tkinter._XYScrollCommand = ...,
) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ...
) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ...
@overload
def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ...
# 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]] = ...,
cnf: Dict[str, Any] | None = ...,
*,
background: tkinter._Color = ...,
cursor: tkinter._Cursor = ...,
@@ -276,7 +276,7 @@ class Combobox(Entry):
height: int = ...,
invalidcommand: tkinter._EntryValidateCommand = ...,
justify: Literal["left", "center", "right"] = ...,
postcommand: Union[Callable[[], Any], str] = ...,
postcommand: Callable[[], Any] | str = ...,
show: Any = ...,
state: str = ...,
style: str = ...,
@@ -287,16 +287,16 @@ class Combobox(Entry):
values: tkinter._TkinterSequence[str] = ...,
width: int = ...,
xscrollcommand: tkinter._XYScrollCommand = ...,
) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ...
) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ...
@overload
def config(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ...
def current(self, newindex: Optional[Any] = ...): ...
def current(self, newindex: Any | None = ...): ...
def set(self, value): ...
class Frame(Widget):
def __init__(
self,
master: Optional[tkinter.Misc] = ...,
master: tkinter.Misc | None = ...,
*,
border: tkinter._ScreenUnits = ...,
borderwidth: tkinter._ScreenUnits = ...,
@@ -313,7 +313,7 @@ class Frame(Widget):
@overload
def configure(
self,
cnf: Optional[Dict[str, Any]] = ...,
cnf: Dict[str, Any] | None = ...,
*,
border: tkinter._ScreenUnits = ...,
borderwidth: tkinter._ScreenUnits = ...,
@@ -324,7 +324,7 @@ class Frame(Widget):
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
width: tkinter._ScreenUnits = ...,
) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ...
) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ...
@overload
def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ...
config = configure
@@ -332,7 +332,7 @@ class Frame(Widget):
class Label(Widget):
def __init__(
self,
master: Optional[tkinter.Misc] = ...,
master: tkinter.Misc | None = ...,
*,
anchor: tkinter._Anchor = ...,
background: tkinter._Color = ...,
@@ -351,16 +351,16 @@ class Label(Widget):
state: str = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
text: Union[float, str] = ...,
text: float | str = ...,
textvariable: tkinter.Variable = ...,
underline: int = ...,
width: Union[int, Literal[""]] = ...,
width: int | Literal[""] = ...,
wraplength: tkinter._ScreenUnits = ...,
) -> None: ...
@overload
def configure(
self,
cnf: Optional[Dict[str, Any]] = ...,
cnf: Dict[str, Any] | None = ...,
*,
anchor: tkinter._Anchor = ...,
background: tkinter._Color = ...,
@@ -377,12 +377,12 @@ class Label(Widget):
state: str = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
text: Union[float, str] = ...,
text: float | str = ...,
textvariable: tkinter.Variable = ...,
underline: int = ...,
width: Union[int, Literal[""]] = ...,
width: int | Literal[""] = ...,
wraplength: tkinter._ScreenUnits = ...,
) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ...
) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ...
@overload
def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ...
config = configure
@@ -390,7 +390,7 @@ class Label(Widget):
class Labelframe(Widget):
def __init__(
self,
master: Optional[tkinter.Misc] = ...,
master: tkinter.Misc | None = ...,
*,
border: tkinter._ScreenUnits = ...,
borderwidth: tkinter._ScreenUnits = ..., # undocumented
@@ -404,14 +404,14 @@ class Labelframe(Widget):
relief: tkinter._Relief = ..., # undocumented
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
text: Union[float, str] = ...,
text: float | str = ...,
underline: int = ...,
width: tkinter._ScreenUnits = ...,
) -> None: ...
@overload
def configure(
self,
cnf: Optional[Dict[str, Any]] = ...,
cnf: Dict[str, Any] | None = ...,
*,
border: tkinter._ScreenUnits = ...,
borderwidth: tkinter._ScreenUnits = ...,
@@ -423,10 +423,10 @@ class Labelframe(Widget):
relief: tkinter._Relief = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
text: Union[float, str] = ...,
text: float | str = ...,
underline: int = ...,
width: tkinter._ScreenUnits = ...,
) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ...
) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ...
@overload
def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ...
config = configure
@@ -436,7 +436,7 @@ LabelFrame = Labelframe
class Menubutton(Widget):
def __init__(
self,
master: Optional[tkinter.Misc] = ...,
master: tkinter.Misc | None = ...,
*,
class_: str = ...,
compound: _TtkCompound = ...,
@@ -449,15 +449,15 @@ class Menubutton(Widget):
state: str = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
text: Union[float, str] = ...,
text: float | str = ...,
textvariable: tkinter.Variable = ...,
underline: int = ...,
width: Union[int, Literal[""]] = ...,
width: int | Literal[""] = ...,
) -> None: ...
@overload
def configure(
self,
cnf: Optional[Dict[str, Any]] = ...,
cnf: Dict[str, Any] | None = ...,
*,
compound: _TtkCompound = ...,
cursor: tkinter._Cursor = ...,
@@ -468,11 +468,11 @@ class Menubutton(Widget):
state: str = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
text: Union[float, str] = ...,
text: float | str = ...,
textvariable: tkinter.Variable = ...,
underline: int = ...,
width: Union[int, Literal[""]] = ...,
) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ...
width: int | Literal[""] = ...,
) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ...
@overload
def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ...
config = configure
@@ -480,7 +480,7 @@ class Menubutton(Widget):
class Notebook(Widget):
def __init__(
self,
master: Optional[tkinter.Misc] = ...,
master: tkinter.Misc | None = ...,
*,
class_: str = ...,
cursor: tkinter._Cursor = ...,
@@ -494,7 +494,7 @@ class Notebook(Widget):
@overload
def configure(
self,
cnf: Optional[Dict[str, Any]] = ...,
cnf: Dict[str, Any] | None = ...,
*,
cursor: tkinter._Cursor = ...,
height: int = ...,
@@ -502,7 +502,7 @@ class Notebook(Widget):
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
width: int = ...,
) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ...
) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ...
@overload
def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ...
config = configure
@@ -512,15 +512,15 @@ class Notebook(Widget):
def identify(self, x, y): ...
def index(self, tab_id): ...
def insert(self, pos, child, **kw): ...
def select(self, tab_id: Optional[Any] = ...): ...
def tab(self, tab_id, option: Optional[Any] = ..., **kw): ...
def select(self, tab_id: Any | None = ...): ...
def tab(self, tab_id, option: Any | None = ..., **kw): ...
def tabs(self): ...
def enable_traversal(self): ...
class Panedwindow(Widget, tkinter.PanedWindow):
def __init__(
self,
master: Optional[tkinter.Misc] = ...,
master: tkinter.Misc | None = ...,
*,
class_: str = ...,
cursor: tkinter._Cursor = ...,
@@ -535,41 +535,41 @@ class Panedwindow(Widget, tkinter.PanedWindow):
@overload # type: ignore
def configure(
self,
cnf: Optional[Dict[str, Any]] = ...,
cnf: Dict[str, Any] | None = ...,
*,
cursor: tkinter._Cursor = ...,
height: int = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
width: int = ...,
) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ...
) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ...
@overload
def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ...
# 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]] = ...,
cnf: Dict[str, Any] | None = ...,
*,
cursor: tkinter._Cursor = ...,
height: int = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
width: int = ...,
) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ...
) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ...
@overload
def config(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ...
forget: Any
def insert(self, pos, child, **kw): ...
def pane(self, pane, option: Optional[Any] = ..., **kw): ...
def sashpos(self, index, newpos: Optional[Any] = ...): ...
def pane(self, pane, option: Any | None = ..., **kw): ...
def sashpos(self, index, newpos: Any | None = ...): ...
PanedWindow = Panedwindow
class Progressbar(Widget):
def __init__(
self,
master: Optional[tkinter.Misc] = ...,
master: tkinter.Misc | None = ...,
*,
class_: str = ...,
cursor: tkinter._Cursor = ...,
@@ -582,12 +582,12 @@ class Progressbar(Widget):
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
value: float = ...,
variable: Union[tkinter.IntVar, tkinter.DoubleVar] = ...,
variable: tkinter.IntVar | tkinter.DoubleVar = ...,
) -> None: ...
@overload
def configure(
self,
cnf: Optional[Dict[str, Any]] = ...,
cnf: Dict[str, Any] | None = ...,
*,
cursor: tkinter._Cursor = ...,
length: tkinter._ScreenUnits = ...,
@@ -598,19 +598,19 @@ class Progressbar(Widget):
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
value: float = ...,
variable: Union[tkinter.IntVar, tkinter.DoubleVar] = ...,
) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ...
variable: tkinter.IntVar | tkinter.DoubleVar = ...,
) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ...
@overload
def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ...
config = configure
def start(self, interval: Optional[Any] = ...): ...
def step(self, amount: Optional[Any] = ...): ...
def start(self, interval: Any | None = ...): ...
def step(self, amount: Any | None = ...): ...
def stop(self): ...
class Radiobutton(Widget):
def __init__(
self,
master: Optional[tkinter.Misc] = ...,
master: tkinter.Misc | None = ...,
*,
class_: str = ...,
command: tkinter._ButtonCommand = ...,
@@ -622,17 +622,17 @@ class Radiobutton(Widget):
state: str = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
text: Union[float, str] = ...,
text: float | str = ...,
textvariable: tkinter.Variable = ...,
underline: int = ...,
value: Any = ...,
variable: Union[tkinter.Variable, Literal[""]] = ...,
width: Union[int, Literal[""]] = ...,
variable: tkinter.Variable | Literal[""] = ...,
width: int | Literal[""] = ...,
) -> None: ...
@overload
def configure(
self,
cnf: Optional[Dict[str, Any]] = ...,
cnf: Dict[str, Any] | None = ...,
*,
command: tkinter._ButtonCommand = ...,
compound: _TtkCompound = ...,
@@ -642,13 +642,13 @@ class Radiobutton(Widget):
state: str = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
text: Union[float, str] = ...,
text: float | str = ...,
textvariable: tkinter.Variable = ...,
underline: int = ...,
value: Any = ...,
variable: Union[tkinter.Variable, Literal[""]] = ...,
width: Union[int, Literal[""]] = ...,
) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ...
variable: tkinter.Variable | Literal[""] = ...,
width: int | Literal[""] = ...,
) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ...
@overload
def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ...
config = configure
@@ -657,10 +657,10 @@ class Radiobutton(Widget):
class Scale(Widget, tkinter.Scale):
def __init__(
self,
master: Optional[tkinter.Misc] = ...,
master: tkinter.Misc | None = ...,
*,
class_: str = ...,
command: Union[str, Callable[[str], Any]] = ...,
command: str | Callable[[str], Any] = ...,
cursor: tkinter._Cursor = ...,
from_: float = ...,
length: tkinter._ScreenUnits = ...,
@@ -671,14 +671,14 @@ class Scale(Widget, tkinter.Scale):
takefocus: tkinter._TakeFocusValue = ...,
to: float = ...,
value: float = ...,
variable: Union[tkinter.IntVar, tkinter.DoubleVar] = ...,
variable: tkinter.IntVar | tkinter.DoubleVar = ...,
) -> None: ...
@overload # type: ignore
def configure(
self,
cnf: Optional[Dict[str, Any]] = ...,
cnf: Dict[str, Any] | None = ...,
*,
command: Union[str, Callable[[str], Any]] = ...,
command: str | Callable[[str], Any] = ...,
cursor: tkinter._Cursor = ...,
from_: float = ...,
length: tkinter._ScreenUnits = ...,
@@ -688,17 +688,17 @@ class Scale(Widget, tkinter.Scale):
takefocus: tkinter._TakeFocusValue = ...,
to: float = ...,
value: float = ...,
variable: Union[tkinter.IntVar, tkinter.DoubleVar] = ...,
) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ...
variable: tkinter.IntVar | tkinter.DoubleVar = ...,
) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ...
@overload
def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ...
# 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]] = ...,
cnf: Dict[str, Any] | None = ...,
*,
command: Union[str, Callable[[str], Any]] = ...,
command: str | Callable[[str], Any] = ...,
cursor: tkinter._Cursor = ...,
from_: float = ...,
length: tkinter._ScreenUnits = ...,
@@ -708,19 +708,19 @@ class Scale(Widget, tkinter.Scale):
takefocus: tkinter._TakeFocusValue = ...,
to: float = ...,
value: float = ...,
variable: Union[tkinter.IntVar, tkinter.DoubleVar] = ...,
) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ...
variable: tkinter.IntVar | tkinter.DoubleVar = ...,
) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ...
@overload
def config(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ...
def get(self, x: Optional[Any] = ..., y: Optional[Any] = ...): ...
def get(self, x: Any | None = ..., y: Any | None = ...): ...
class Scrollbar(Widget, tkinter.Scrollbar):
def __init__(
self,
master: Optional[tkinter.Misc] = ...,
master: tkinter.Misc | None = ...,
*,
class_: str = ...,
command: Union[Callable[..., Optional[Tuple[float, float]]], str] = ...,
command: Callable[..., Tuple[float, float] | None] | str = ...,
cursor: tkinter._Cursor = ...,
name: str = ...,
orient: Literal["horizontal", "vertical"] = ...,
@@ -730,35 +730,35 @@ class Scrollbar(Widget, tkinter.Scrollbar):
@overload # type: ignore
def configure(
self,
cnf: Optional[Dict[str, Any]] = ...,
cnf: Dict[str, Any] | None = ...,
*,
command: Union[Callable[..., Optional[Tuple[float, float]]], str] = ...,
command: Callable[..., Tuple[float, float] | None] | str = ...,
cursor: tkinter._Cursor = ...,
orient: Literal["horizontal", "vertical"] = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ...
) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ...
@overload
def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ...
# 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]] = ...,
cnf: Dict[str, Any] | None = ...,
*,
command: Union[Callable[..., Optional[Tuple[float, float]]], str] = ...,
command: Callable[..., Tuple[float, float] | None] | str = ...,
cursor: tkinter._Cursor = ...,
orient: Literal["horizontal", "vertical"] = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ...
) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ...
@overload
def config(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ...
class Separator(Widget):
def __init__(
self,
master: Optional[tkinter.Misc] = ...,
master: tkinter.Misc | None = ...,
*,
class_: str = ...,
cursor: tkinter._Cursor = ...,
@@ -770,13 +770,13 @@ class Separator(Widget):
@overload
def configure(
self,
cnf: Optional[Dict[str, Any]] = ...,
cnf: Dict[str, Any] | None = ...,
*,
cursor: tkinter._Cursor = ...,
orient: Literal["horizontal", "vertical"] = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ...
) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ...
@overload
def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ...
config = configure
@@ -784,7 +784,7 @@ class Separator(Widget):
class Sizegrip(Widget):
def __init__(
self,
master: Optional[tkinter.Misc] = ...,
master: tkinter.Misc | None = ...,
*,
class_: str = ...,
cursor: tkinter._Cursor = ...,
@@ -795,12 +795,12 @@ class Sizegrip(Widget):
@overload
def configure(
self,
cnf: Optional[Dict[str, Any]] = ...,
cnf: Dict[str, Any] | None = ...,
*,
cursor: tkinter._Cursor = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ...
) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ...
@overload
def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ...
config = configure
@@ -809,11 +809,11 @@ if sys.version_info >= (3, 7):
class Spinbox(Entry):
def __init__(
self,
master: Optional[tkinter.Misc] = ...,
master: tkinter.Misc | None = ...,
*,
background: tkinter._Color = ..., # undocumented
class_: str = ...,
command: Union[Callable[[], Any], str, tkinter._TkinterSequence[str]] = ...,
command: Callable[[], Any] | str | tkinter._TkinterSequence[str] = ...,
cursor: tkinter._Cursor = ...,
exportselection: bool = ..., # undocumented
font: _FontDescription = ..., # undocumented
@@ -840,10 +840,10 @@ if sys.version_info >= (3, 7):
@overload # type: ignore
def configure(
self,
cnf: Optional[Dict[str, Any]] = ...,
cnf: Dict[str, Any] | None = ...,
*,
background: tkinter._Color = ...,
command: Union[Callable[[], Any], str, tkinter._TkinterSequence[str]] = ...,
command: Callable[[], Any] | str | tkinter._TkinterSequence[str] = ...,
cursor: tkinter._Cursor = ...,
exportselection: bool = ...,
font: _FontDescription = ...,
@@ -865,7 +865,7 @@ if sys.version_info >= (3, 7):
width: int = ...,
wrap: bool = ...,
xscrollcommand: tkinter._XYScrollCommand = ...,
) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ...
) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ...
@overload
def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ...
config = configure # type: ignore
@@ -904,12 +904,12 @@ _TreeviewColumnId = Union[int, str] # manual page: "COLUMN IDENTIFIERS"
class Treeview(Widget, tkinter.XView, tkinter.YView):
def __init__(
self,
master: Optional[tkinter.Misc] = ...,
master: tkinter.Misc | None = ...,
*,
class_: str = ...,
columns: Union[str, tkinter._TkinterSequence[str]] = ...,
columns: str | tkinter._TkinterSequence[str] = ...,
cursor: tkinter._Cursor = ...,
displaycolumns: Union[str, tkinter._TkinterSequence[str], tkinter._TkinterSequence[int], Literal["#all"]] = ...,
displaycolumns: str | tkinter._TkinterSequence[str] | tkinter._TkinterSequence[int] | Literal["#all"] = ...,
height: int = ...,
name: str = ...,
padding: tkinter._Padding = ...,
@@ -918,7 +918,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView):
#
# 'tree headings' is same as ['tree', 'headings'], and I wouldn't be
# surprised if someone was using it.
show: Union[Literal["tree", "headings", "tree headings"], tkinter._TkinterSequence[str]] = ...,
show: Literal["tree", "headings", "tree headings"] | tkinter._TkinterSequence[str] = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
xscrollcommand: tkinter._XYScrollCommand = ...,
@@ -927,20 +927,20 @@ class Treeview(Widget, tkinter.XView, tkinter.YView):
@overload
def configure(
self,
cnf: Optional[Dict[str, Any]] = ...,
cnf: Dict[str, Any] | None = ...,
*,
columns: Union[str, tkinter._TkinterSequence[str]] = ...,
columns: str | tkinter._TkinterSequence[str] = ...,
cursor: tkinter._Cursor = ...,
displaycolumns: Union[str, tkinter._TkinterSequence[str], tkinter._TkinterSequence[int], Literal["#all"]] = ...,
displaycolumns: str | tkinter._TkinterSequence[str] | tkinter._TkinterSequence[int] | Literal["#all"] = ...,
height: int = ...,
padding: tkinter._Padding = ...,
selectmode: Literal["extended", "browse", "none"] = ...,
show: Union[Literal["tree", "headings", "tree headings"], tkinter._TkinterSequence[str]] = ...,
show: Literal["tree", "headings", "tree headings"] | tkinter._TkinterSequence[str] = ...,
style: str = ...,
takefocus: tkinter._TakeFocusValue = ...,
xscrollcommand: tkinter._XYScrollCommand = ...,
yscrollcommand: tkinter._XYScrollCommand = ...,
) -> Optional[Dict[str, Tuple[str, str, str, Any, Any]]]: ...
) -> Dict[str, Tuple[str, str, str, Any, Any]] | None: ...
@overload
def configure(self, cnf: str) -> Tuple[str, str, str, Any, Any]: ...
config = configure
@@ -1049,7 +1049,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView):
if sys.version_info >= (3, 8):
def selection(self) -> Tuple[str, ...]: ...
else:
def selection(self, selop: Optional[Any] = ..., items: Optional[Any] = ...) -> Tuple[str, ...]: ...
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: ...
@@ -1064,10 +1064,10 @@ class Treeview(Widget, tkinter.XView, tkinter.YView):
# Also, it's 'callback' instead of 'func' here.
@overload
def tag_bind(
self, tagname: str, sequence: Optional[str] = ..., callback: Optional[Callable[[tkinter.Event[Treeview]], Any]] = ...
self, tagname: str, sequence: str | None = ..., callback: Callable[[tkinter.Event[Treeview]], Any] | None = ...
) -> str: ...
@overload
def tag_bind(self, tagname: str, sequence: Optional[str], callback: str) -> None: ...
def tag_bind(self, tagname: str, sequence: str | None, callback: str) -> None: ...
@overload
def tag_bind(self, tagname: str, *, callback: str) -> None: ...
@overload
@@ -1103,12 +1103,12 @@ class LabeledScale(Frame):
# TODO: don't any-type **kw. That goes to Frame.__init__.
def __init__(
self,
master: Optional[tkinter.Misc] = ...,
variable: Optional[Union[tkinter.IntVar, tkinter.DoubleVar]] = ...,
master: tkinter.Misc | None = ...,
variable: tkinter.IntVar | tkinter.DoubleVar | None = ...,
from_: float = ...,
to: float = ...,
*,
compound: Union[Literal["top"], Literal["bottom"]] = ...,
compound: Literal["top"] | Literal["bottom"] = ...,
**kw: Any,
) -> None: ...
# destroy is overrided, signature does not change
@@ -1119,13 +1119,13 @@ class OptionMenu(Menubutton):
self,
master,
variable,
default: Optional[str] = ...,
default: str | None = ...,
*values: str,
# rest of these are keyword-only because *args syntax used above
style: str = ...,
direction: Union[Literal["above"], Literal["below"], Literal["left"], Literal["right"], Literal["flush"]] = ...,
command: Optional[Callable[[tkinter.StringVar], Any]] = ...,
direction: Literal["above"] | Literal["below"] | Literal["left"] | Literal["right"] | Literal["flush"] = ...,
command: Callable[[tkinter.StringVar], Any] | None = ...,
) -> None: ...
# configure, config, cget, destroy are inherited from Menubutton
# destroy and __setitem__ are overrided, signature does not change
def set_menu(self, default: Optional[Any] = ..., *values): ...
def set_menu(self, default: Any | None = ..., *values): ...