From a283c0122cd0bd3ea2e91862e924e3b92904620b Mon Sep 17 00:00:00 2001 From: Avasam Date: Thu, 27 Mar 2025 18:54:35 -0400 Subject: [PATCH 1/4] Enable Ruff flake8-import-conventions (ICN) --- pyproject.toml | 4 + stdlib/tkinter/font.pyi | 32 +- stdlib/tkinter/tix.pyi | 104 ++--- stdlib/tkinter/ttk.pyi | 498 ++++++++++----------- stubs/JACK-Client/jack/__init__.pyi | 4 +- stubs/networkx/networkx/classes/graph.pyi | 4 +- stubs/networkx/networkx/convert_matrix.pyi | 18 +- stubs/networkx/networkx/drawing/layout.pyi | 4 +- stubs/networkx/networkx/utils/misc.pyi | 6 +- stubs/tensorflow/tensorflow/_aliases.pyi | 2 +- stubs/ttkthemes/ttkthemes/themed_style.pyi | 4 +- stubs/ttkthemes/ttkthemes/themed_tk.pyi | 4 +- 12 files changed, 344 insertions(+), 340 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 7adabb9eab66..440b85dc3cdf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,6 +50,7 @@ select = [ "EXE", # flake8-executable "FA", # flake8-future-annotations "I", # isort + "ICN", # flake8-import-conventions "N", # pep8-naming "PGH", # pygrep-hooks "PLC", # Pylint Convention @@ -204,6 +205,9 @@ ignore = [ [tool.ruff.lint.pydocstyle] convention = "pep257" # https://docs.astral.sh/ruff/settings/#lint_pydocstyle_convention +[tool.lint.flake8-import-conventions.extend-aliases] +"numpy.typing" = "npt" + [tool.ruff.lint.isort] split-on-trailing-comma = false combine-as-imports = true diff --git a/stdlib/tkinter/font.pyi b/stdlib/tkinter/font.pyi index 3b73f982c4ca..fd2df5474b10 100644 --- a/stdlib/tkinter/font.pyi +++ b/stdlib/tkinter/font.pyi @@ -1,7 +1,7 @@ import _tkinter import itertools import sys -import tkinter +import tkinter as tk from typing import Any, ClassVar, Final, Literal, TypedDict, overload from typing_extensions import TypeAlias, Unpack @@ -46,7 +46,7 @@ class Font: self, # In tkinter, 'root' refers to tkinter.Tk by convention, but the code # actually works with any tkinter widget so we use tkinter.Misc. - root: tkinter.Misc | None = None, + root: tk.Misc | None = None, font: _FontDescription | None = None, name: str | None = None, exists: bool = False, @@ -74,19 +74,19 @@ class Font: def cget(self, option: str) -> Any: ... __getitem__ = cget @overload - def actual(self, option: Literal["family"], displayof: tkinter.Misc | None = None) -> str: ... + def actual(self, option: Literal["family"], displayof: tk.Misc | None = None) -> str: ... @overload - def actual(self, option: Literal["size"], displayof: tkinter.Misc | None = None) -> int: ... + def actual(self, option: Literal["size"], displayof: tk.Misc | None = None) -> int: ... @overload - def actual(self, option: Literal["weight"], displayof: tkinter.Misc | None = None) -> Literal["normal", "bold"]: ... + def actual(self, option: Literal["weight"], displayof: tk.Misc | None = None) -> Literal["normal", "bold"]: ... @overload - def actual(self, option: Literal["slant"], displayof: tkinter.Misc | None = None) -> Literal["roman", "italic"]: ... + def actual(self, option: Literal["slant"], displayof: tk.Misc | None = None) -> Literal["roman", "italic"]: ... @overload - def actual(self, option: Literal["underline", "overstrike"], displayof: tkinter.Misc | None = None) -> bool: ... + def actual(self, option: Literal["underline", "overstrike"], displayof: tk.Misc | None = None) -> bool: ... @overload - def actual(self, option: None, displayof: tkinter.Misc | None = None) -> _FontDict: ... + def actual(self, option: None, displayof: tk.Misc | None = None) -> _FontDict: ... @overload - def actual(self, *, displayof: tkinter.Misc | None = None) -> _FontDict: ... + def actual(self, *, displayof: tk.Misc | None = None) -> _FontDict: ... def config( self, *, @@ -100,20 +100,20 @@ class Font: configure = config def copy(self) -> Font: ... @overload - def metrics(self, option: Literal["ascent", "descent", "linespace"], /, *, displayof: tkinter.Misc | None = ...) -> int: ... + def metrics(self, option: Literal["ascent", "descent", "linespace"], /, *, displayof: tk.Misc | None = ...) -> int: ... @overload - def metrics(self, option: Literal["fixed"], /, *, displayof: tkinter.Misc | None = ...) -> bool: ... + def metrics(self, option: Literal["fixed"], /, *, displayof: tk.Misc | None = ...) -> bool: ... @overload - def metrics(self, *, displayof: tkinter.Misc | None = ...) -> _MetricsDict: ... - def measure(self, text: str, displayof: tkinter.Misc | None = None) -> int: ... + def metrics(self, *, displayof: tk.Misc | None = ...) -> _MetricsDict: ... + def measure(self, text: str, displayof: tk.Misc | None = None) -> int: ... def __eq__(self, other: object) -> bool: ... def __del__(self) -> None: ... -def families(root: tkinter.Misc | None = None, displayof: tkinter.Misc | None = None) -> tuple[str, ...]: ... -def names(root: tkinter.Misc | None = None) -> tuple[str, ...]: ... +def families(root: tk.Misc | None = None, displayof: tk.Misc | None = None) -> tuple[str, ...]: ... +def names(root: tk.Misc | None = None) -> tuple[str, ...]: ... if sys.version_info >= (3, 10): - def nametofont(name: str, root: tkinter.Misc | None = None) -> Font: ... + def nametofont(name: str, root: tk.Misc | None = None) -> Font: ... else: def nametofont(name: str) -> Font: ... diff --git a/stdlib/tkinter/tix.pyi b/stdlib/tkinter/tix.pyi index 7891364fa02c..2aeb57544f8d 100644 --- a/stdlib/tkinter/tix.pyi +++ b/stdlib/tkinter/tix.pyi @@ -1,4 +1,4 @@ -import tkinter +import tkinter as tk from _typeshed import Incomplete from typing import Any, Final @@ -44,13 +44,13 @@ class tixCommand: def tix_option_get(self, name: str) -> Any: ... def tix_resetoptions(self, newScheme: str, newFontSet: str, newScmPrio: str | None = None) -> None: ... -class Tk(tkinter.Tk, tixCommand): +class Tk(tk.Tk, tixCommand): def __init__(self, screenName: str | None = None, baseName: str | None = None, className: str = "Tix") -> None: ... -class TixWidget(tkinter.Widget): +class TixWidget(tk.Widget): def __init__( self, - master: tkinter.Misc | None = None, + master: tk.Misc | None = None, widgetName: str | None = None, static_options: list[str] | None = None, cnf: dict[str, Any] = {}, @@ -58,56 +58,56 @@ class TixWidget(tkinter.Widget): ) -> None: ... def __getattr__(self, name: str): ... def set_silent(self, value: str) -> None: ... - def subwidget(self, name: str) -> tkinter.Widget: ... - def subwidgets_all(self) -> list[tkinter.Widget]: ... + def subwidget(self, name: str) -> tk.Widget: ... + def subwidgets_all(self) -> list[tk.Widget]: ... def config_all(self, option: Any, value: Any) -> None: ... - def image_create(self, imgtype: str, cnf: dict[str, Any] = {}, master: tkinter.Widget | None = None, **kw) -> None: ... + def image_create(self, imgtype: str, cnf: dict[str, Any] = {}, master: tk.Widget | None = None, **kw) -> None: ... def image_delete(self, imgname: str) -> None: ... class TixSubWidget(TixWidget): - def __init__(self, master: tkinter.Widget, name: str, destroy_physically: int = 1, check_intermediate: int = 1) -> None: ... + def __init__(self, master: tk.Widget, name: str, destroy_physically: int = 1, check_intermediate: int = 1) -> None: ... class DisplayStyle: - def __init__(self, itemtype: str, cnf: dict[str, Any] = {}, *, master: tkinter.Widget | None = None, **kw) -> None: ... + def __init__(self, itemtype: str, cnf: dict[str, Any] = {}, *, master: tk.Widget | None = None, **kw) -> None: ... def __getitem__(self, key: str): ... def __setitem__(self, key: str, value: Any) -> None: ... def delete(self) -> None: ... def config(self, cnf: dict[str, Any] = {}, **kw): ... class Balloon(TixWidget): - def __init__(self, master: tkinter.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... - def bind_widget(self, widget: tkinter.Widget, cnf: dict[str, Any] = {}, **kw) -> None: ... - def unbind_widget(self, widget: tkinter.Widget) -> None: ... + def __init__(self, master: tk.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def bind_widget(self, widget: tk.Widget, cnf: dict[str, Any] = {}, **kw) -> None: ... + def unbind_widget(self, widget: tk.Widget) -> None: ... class ButtonBox(TixWidget): - def __init__(self, master: tkinter.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... - def add(self, name: str, cnf: dict[str, Any] = {}, **kw) -> tkinter.Widget: ... + def __init__(self, master: tk.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def add(self, name: str, cnf: dict[str, Any] = {}, **kw) -> tk.Widget: ... def invoke(self, name: str) -> None: ... class ComboBox(TixWidget): - def __init__(self, master: tkinter.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tk.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... def add_history(self, str: str) -> None: ... def append_history(self, str: str) -> None: ... def insert(self, index: int, str: str) -> None: ... def pick(self, index: int) -> None: ... class Control(TixWidget): - def __init__(self, master: tkinter.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tk.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... def decrement(self) -> None: ... def increment(self) -> None: ... def invoke(self) -> None: ... class LabelEntry(TixWidget): - def __init__(self, master: tkinter.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tk.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... class LabelFrame(TixWidget): - def __init__(self, master: tkinter.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tk.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... class Meter(TixWidget): - def __init__(self, master: tkinter.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tk.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... class OptionMenu(TixWidget): - def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tk.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... def add_command(self, name: str, cnf: dict[str, Any] = {}, **kw) -> None: ... def add_separator(self, name: str, cnf: dict[str, Any] = {}, **kw) -> None: ... def delete(self, name: str) -> None: ... @@ -115,55 +115,55 @@ class OptionMenu(TixWidget): def enable(self, name: str) -> None: ... class PopupMenu(TixWidget): - def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... - def bind_widget(self, widget: tkinter.Widget) -> None: ... - def unbind_widget(self, widget: tkinter.Widget) -> None: ... - def post_widget(self, widget: tkinter.Widget, x: int, y: int) -> None: ... + def __init__(self, master: tk.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def bind_widget(self, widget: tk.Widget) -> None: ... + def unbind_widget(self, widget: tk.Widget) -> None: ... + def post_widget(self, widget: tk.Widget, x: int, y: int) -> None: ... class Select(TixWidget): - def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... - def add(self, name: str, cnf: dict[str, Any] = {}, **kw) -> tkinter.Widget: ... + def __init__(self, master: tk.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def add(self, name: str, cnf: dict[str, Any] = {}, **kw) -> tk.Widget: ... def invoke(self, name: str) -> None: ... class StdButtonBox(TixWidget): - def __init__(self, master: tkinter.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tk.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... def invoke(self, name: str) -> None: ... class DirList(TixWidget): - def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tk.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... def chdir(self, dir: str) -> None: ... class DirTree(TixWidget): - def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tk.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... def chdir(self, dir: str) -> None: ... class DirSelectDialog(TixWidget): - def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tk.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... def popup(self) -> None: ... def popdown(self) -> None: ... class DirSelectBox(TixWidget): - def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tk.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... class ExFileSelectBox(TixWidget): - def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tk.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... def filter(self) -> None: ... def invoke(self) -> None: ... class FileSelectBox(TixWidget): - def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tk.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... def apply_filter(self) -> None: ... def invoke(self) -> None: ... class FileEntry(TixWidget): - def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tk.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... def invoke(self) -> None: ... def file_dialog(self) -> None: ... -class HList(TixWidget, tkinter.XView, tkinter.YView): - def __init__(self, master: tkinter.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... - def add(self, entry: str, cnf: dict[str, Any] = {}, **kw) -> tkinter.Widget: ... - def add_child(self, parent: str | None = None, cnf: dict[str, Any] = {}, **kw) -> tkinter.Widget: ... +class HList(TixWidget, tk.XView, tk.YView): + def __init__(self, master: tk.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def add(self, entry: str, cnf: dict[str, Any] = {}, **kw) -> tk.Widget: ... + def add_child(self, parent: str | None = None, cnf: dict[str, Any] = {}, **kw) -> tk.Widget: ... def anchor_set(self, entry: str) -> None: ... def anchor_clear(self) -> None: ... # FIXME: Overload, certain combos return, others don't @@ -217,7 +217,7 @@ class HList(TixWidget, tkinter.XView, tkinter.YView): def show_entry(self, entry: str) -> None: ... class CheckList(TixWidget): - def __init__(self, master: tkinter.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tk.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... def autosetmode(self) -> None: ... def close(self, entrypath: str) -> None: ... def getmode(self, entrypath: str) -> str: ... @@ -227,15 +227,15 @@ class CheckList(TixWidget): def setstatus(self, entrypath: str, mode: str = "on") -> None: ... class Tree(TixWidget): - def __init__(self, master: tkinter.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tk.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... def autosetmode(self) -> None: ... def close(self, entrypath: str) -> None: ... def getmode(self, entrypath: str) -> str: ... def open(self, entrypath: str) -> None: ... def setmode(self, entrypath: str, mode: str = "none") -> None: ... -class TList(TixWidget, tkinter.XView, tkinter.YView): - def __init__(self, master: tkinter.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... +class TList(TixWidget, tk.XView, tk.YView): + def __init__(self, master: tk.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... def active_set(self, index: int) -> None: ... def active_clear(self) -> None: ... def anchor_set(self, index: int) -> None: ... @@ -261,32 +261,32 @@ class TList(TixWidget, tkinter.XView, tkinter.YView): def selection_set(self, first: int, last: int | None = None) -> None: ... class PanedWindow(TixWidget): - def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tk.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... def add(self, name: str, cnf: dict[str, Any] = {}, **kw) -> None: ... def delete(self, name: str) -> None: ... def forget(self, name: str) -> None: ... # type: ignore[override] def panecget(self, entry: str, opt): ... def paneconfigure(self, entry: str, cnf: dict[str, Any] = {}, **kw) -> Incomplete | None: ... - def panes(self) -> list[tkinter.Widget]: ... + def panes(self) -> list[tk.Widget]: ... class ListNoteBook(TixWidget): - def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tk.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... def add(self, name: str, cnf: dict[str, Any] = {}, **kw) -> None: ... - def page(self, name: str) -> tkinter.Widget: ... - def pages(self) -> list[tkinter.Widget]: ... + def page(self, name: str) -> tk.Widget: ... + def pages(self) -> list[tk.Widget]: ... def raise_page(self, name: str) -> None: ... class NoteBook(TixWidget): - def __init__(self, master: tkinter.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tk.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... def add(self, name: str, cnf: dict[str, Any] = {}, **kw) -> None: ... def delete(self, name: str) -> None: ... - def page(self, name: str) -> tkinter.Widget: ... - def pages(self) -> list[tkinter.Widget]: ... + def page(self, name: str) -> tk.Widget: ... + def pages(self) -> list[tk.Widget]: ... def raise_page(self, name: str) -> None: ... def raised(self) -> bool: ... class InputOnly(TixWidget): - def __init__(self, master: tkinter.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tk.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... class Form: def __setitem__(self, key: str, value: Any) -> None: ... @@ -296,4 +296,4 @@ class Form: def forget(self) -> None: ... def grid(self, xsize: int = 0, ysize: int = 0) -> tuple[int, int] | None: ... def info(self, option: str | None = None): ... - def slaves(self) -> list[tkinter.Widget]: ... + def slaves(self) -> list[tk.Widget]: ... diff --git a/stdlib/tkinter/ttk.pyi b/stdlib/tkinter/ttk.pyi index 5328e461ebdc..eaf26badf024 100644 --- a/stdlib/tkinter/ttk.pyi +++ b/stdlib/tkinter/ttk.pyi @@ -1,5 +1,5 @@ import _tkinter -import tkinter +import tkinter as tk from _typeshed import Incomplete, MaybeNone from collections.abc import Callable from tkinter.font import _FontDescription @@ -38,20 +38,20 @@ def tclobjs_to_py(adict: dict[Any, Any]) -> dict[Any, Any]: ... def setup_master(master: Incomplete | None = None): ... _Padding: TypeAlias = ( - tkinter._ScreenUnits - | tuple[tkinter._ScreenUnits] - | tuple[tkinter._ScreenUnits, tkinter._ScreenUnits] - | tuple[tkinter._ScreenUnits, tkinter._ScreenUnits, tkinter._ScreenUnits] - | tuple[tkinter._ScreenUnits, tkinter._ScreenUnits, tkinter._ScreenUnits, tkinter._ScreenUnits] + tk._ScreenUnits + | tuple[tk._ScreenUnits] + | tuple[tk._ScreenUnits, tk._ScreenUnits] + | tuple[tk._ScreenUnits, tk._ScreenUnits, tk._ScreenUnits] + | tuple[tk._ScreenUnits, tk._ScreenUnits, tk._ScreenUnits, tk._ScreenUnits] ) # from ttk_widget (aka ttk::widget) manual page, differs from tkinter._Compound -_TtkCompound: TypeAlias = Literal["", "text", "image", tkinter._Compound] +_TtkCompound: TypeAlias = Literal["", "text", "image", tk._Compound] class Style: master: Incomplete tk: _tkinter.TkappType - def __init__(self, master: tkinter.Misc | None = None) -> None: ... + def __init__(self, master: tk.Misc | None = None) -> None: ... def configure(self, style, query_opt: Incomplete | None = None, **kw): ... def map(self, style, query_opt: Incomplete | None = None, **kw): ... def lookup(self, style, option, state: Incomplete | None = None, default: Incomplete | None = None): ... @@ -67,8 +67,8 @@ class Style: @overload def theme_use(self, themename: None = None) -> str: ... -class Widget(tkinter.Widget): - def __init__(self, master: tkinter.Misc | None, widgetname, kw: Incomplete | None = None) -> None: ... +class Widget(tk.Widget): + def __init__(self, master: tk.Misc | None, widgetname, kw: Incomplete | None = None) -> None: ... def identify(self, x: int, y: int) -> str: ... def instate(self, statespec, callback: Incomplete | None = None, *args, **kw): ... def state(self, statespec: Incomplete | None = None): ... @@ -76,21 +76,21 @@ class Widget(tkinter.Widget): class Button(Widget): def __init__( self, - master: tkinter.Misc | None = None, + master: tk.Misc | None = None, *, class_: str = "", - command: tkinter._ButtonCommand = "", + command: tk._ButtonCommand = "", compound: _TtkCompound = "", - cursor: tkinter._Cursor = "", + cursor: tk._Cursor = "", default: Literal["normal", "active", "disabled"] = "normal", - image: tkinter._ImageSpec = "", + image: tk._ImageSpec = "", name: str = ..., padding=..., # undocumented state: str = "normal", style: str = "", - takefocus: tkinter._TakeFocusValue = ..., + takefocus: tk._TakeFocusValue = ..., text: float | str = "", - textvariable: tkinter.Variable = ..., + textvariable: tk.Variable = ..., underline: int = -1, width: int | Literal[""] = "", ) -> None: ... @@ -99,17 +99,17 @@ class Button(Widget): self, cnf: dict[str, Any] | None = None, *, - command: tkinter._ButtonCommand = ..., + command: tk._ButtonCommand = ..., compound: _TtkCompound = ..., - cursor: tkinter._Cursor = ..., + cursor: tk._Cursor = ..., default: Literal["normal", "active", "disabled"] = ..., - image: tkinter._ImageSpec = ..., + image: tk._ImageSpec = ..., padding=..., state: str = ..., style: str = ..., - takefocus: tkinter._TakeFocusValue = ..., + takefocus: tk._TakeFocusValue = ..., text: float | str = ..., - textvariable: tkinter.Variable = ..., + textvariable: tk.Variable = ..., underline: int = ..., width: int | Literal[""] = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @@ -121,27 +121,27 @@ class Button(Widget): class Checkbutton(Widget): def __init__( self, - master: tkinter.Misc | None = None, + master: tk.Misc | None = None, *, class_: str = "", - command: tkinter._ButtonCommand = "", + command: tk._ButtonCommand = "", compound: _TtkCompound = "", - cursor: tkinter._Cursor = "", - image: tkinter._ImageSpec = "", + cursor: tk._Cursor = "", + image: tk._ImageSpec = "", name: str = ..., offvalue: Any = 0, onvalue: Any = 1, padding=..., # undocumented state: str = "normal", style: str = "", - takefocus: tkinter._TakeFocusValue = ..., + takefocus: tk._TakeFocusValue = ..., text: float | str = "", - textvariable: tkinter.Variable = ..., + textvariable: tk.Variable = ..., underline: int = -1, # 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 = ..., + variable: tk.Variable = ..., width: int | Literal[""] = "", ) -> None: ... @overload @@ -149,20 +149,20 @@ class Checkbutton(Widget): self, cnf: dict[str, Any] | None = None, *, - command: tkinter._ButtonCommand = ..., + command: tk._ButtonCommand = ..., compound: _TtkCompound = ..., - cursor: tkinter._Cursor = ..., - image: tkinter._ImageSpec = ..., + cursor: tk._Cursor = ..., + image: tk._ImageSpec = ..., offvalue: Any = ..., onvalue: Any = ..., padding=..., state: str = ..., style: str = ..., - takefocus: tkinter._TakeFocusValue = ..., + takefocus: tk._TakeFocusValue = ..., text: float | str = ..., - textvariable: tkinter.Variable = ..., + textvariable: tk.Variable = ..., underline: int = ..., - variable: tkinter.Variable = ..., + variable: tk.Variable = ..., width: int | Literal[""] = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload @@ -170,30 +170,30 @@ class Checkbutton(Widget): config = configure def invoke(self) -> Any: ... -class Entry(Widget, tkinter.Entry): +class Entry(Widget, tk.Entry): def __init__( self, - master: tkinter.Misc | None = None, + master: tk.Misc | None = None, widget: str | None = None, *, background: str = ..., # undocumented class_: str = "", - cursor: tkinter._Cursor = ..., + cursor: tk._Cursor = ..., exportselection: bool = True, font: _FontDescription = "TkTextFont", foreground: str = "", - invalidcommand: tkinter._EntryValidateCommand = "", + invalidcommand: tk._EntryValidateCommand = "", justify: Literal["left", "center", "right"] = "left", name: str = ..., show: str = "", state: str = "normal", style: str = "", - takefocus: tkinter._TakeFocusValue = ..., - textvariable: tkinter.Variable = ..., + takefocus: tk._TakeFocusValue = ..., + textvariable: tk.Variable = ..., validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = "none", - validatecommand: tkinter._EntryValidateCommand = "", + validatecommand: tk._EntryValidateCommand = "", width: int = 20, - xscrollcommand: tkinter._XYScrollCommand = "", + xscrollcommand: tk._XYScrollCommand = "", ) -> None: ... @overload # type: ignore[override] def configure( @@ -201,21 +201,21 @@ class Entry(Widget, tkinter.Entry): cnf: dict[str, Any] | None = None, *, background: str = ..., - cursor: tkinter._Cursor = ..., + cursor: tk._Cursor = ..., exportselection: bool = ..., font: _FontDescription = ..., foreground: str = ..., - invalidcommand: tkinter._EntryValidateCommand = ..., + invalidcommand: tk._EntryValidateCommand = ..., justify: Literal["left", "center", "right"] = ..., show: str = ..., state: str = ..., style: str = ..., - takefocus: tkinter._TakeFocusValue = ..., - textvariable: tkinter.Variable = ..., + takefocus: tk._TakeFocusValue = ..., + textvariable: tk.Variable = ..., validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., - validatecommand: tkinter._EntryValidateCommand = ..., + validatecommand: tk._EntryValidateCommand = ..., width: int = ..., - xscrollcommand: tkinter._XYScrollCommand = ..., + xscrollcommand: tk._XYScrollCommand = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -226,21 +226,21 @@ class Entry(Widget, tkinter.Entry): cnf: dict[str, Any] | None = None, *, background: str = ..., - cursor: tkinter._Cursor = ..., + cursor: tk._Cursor = ..., exportselection: bool = ..., font: _FontDescription = ..., foreground: str = ..., - invalidcommand: tkinter._EntryValidateCommand = ..., + invalidcommand: tk._EntryValidateCommand = ..., justify: Literal["left", "center", "right"] = ..., show: str = ..., state: str = ..., style: str = ..., - takefocus: tkinter._TakeFocusValue = ..., - textvariable: tkinter.Variable = ..., + takefocus: tk._TakeFocusValue = ..., + textvariable: tk.Variable = ..., validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., - validatecommand: tkinter._EntryValidateCommand = ..., + validatecommand: tk._EntryValidateCommand = ..., width: int = ..., - xscrollcommand: tkinter._XYScrollCommand = ..., + xscrollcommand: tk._XYScrollCommand = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def config(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -251,29 +251,29 @@ class Entry(Widget, tkinter.Entry): class Combobox(Entry): def __init__( self, - master: tkinter.Misc | None = None, + master: tk.Misc | None = None, *, background: str = ..., # undocumented class_: str = "", - cursor: tkinter._Cursor = "", + cursor: tk._Cursor = "", exportselection: bool = True, font: _FontDescription = ..., # undocumented foreground: str = ..., # undocumented height: int = 10, - invalidcommand: tkinter._EntryValidateCommand = ..., # undocumented + invalidcommand: tk._EntryValidateCommand = ..., # undocumented justify: Literal["left", "center", "right"] = "left", name: str = ..., postcommand: Callable[[], object] | str = "", show=..., # undocumented state: str = "normal", style: str = "", - takefocus: tkinter._TakeFocusValue = ..., - textvariable: tkinter.Variable = ..., + takefocus: tk._TakeFocusValue = ..., + textvariable: tk.Variable = ..., validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., # undocumented - validatecommand: tkinter._EntryValidateCommand = ..., # undocumented + validatecommand: tk._EntryValidateCommand = ..., # undocumented values: list[str] | tuple[str, ...] = ..., width: int = 20, - xscrollcommand: tkinter._XYScrollCommand = ..., # undocumented + xscrollcommand: tk._XYScrollCommand = ..., # undocumented ) -> None: ... @overload # type: ignore[override] def configure( @@ -281,24 +281,24 @@ class Combobox(Entry): cnf: dict[str, Any] | None = None, *, background: str = ..., - cursor: tkinter._Cursor = ..., + cursor: tk._Cursor = ..., exportselection: bool = ..., font: _FontDescription = ..., foreground: str = ..., height: int = ..., - invalidcommand: tkinter._EntryValidateCommand = ..., + invalidcommand: tk._EntryValidateCommand = ..., justify: Literal["left", "center", "right"] = ..., postcommand: Callable[[], object] | str = ..., show=..., state: str = ..., style: str = ..., - takefocus: tkinter._TakeFocusValue = ..., - textvariable: tkinter.Variable = ..., + takefocus: tk._TakeFocusValue = ..., + textvariable: tk.Variable = ..., validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., - validatecommand: tkinter._EntryValidateCommand = ..., + validatecommand: tk._EntryValidateCommand = ..., values: list[str] | tuple[str, ...] = ..., width: int = ..., - xscrollcommand: tkinter._XYScrollCommand = ..., + xscrollcommand: tk._XYScrollCommand = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -309,24 +309,24 @@ class Combobox(Entry): cnf: dict[str, Any] | None = None, *, background: str = ..., - cursor: tkinter._Cursor = ..., + cursor: tk._Cursor = ..., exportselection: bool = ..., font: _FontDescription = ..., foreground: str = ..., height: int = ..., - invalidcommand: tkinter._EntryValidateCommand = ..., + invalidcommand: tk._EntryValidateCommand = ..., justify: Literal["left", "center", "right"] = ..., postcommand: Callable[[], object] | str = ..., show=..., state: str = ..., style: str = ..., - takefocus: tkinter._TakeFocusValue = ..., - textvariable: tkinter.Variable = ..., + takefocus: tk._TakeFocusValue = ..., + textvariable: tk.Variable = ..., validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., - validatecommand: tkinter._EntryValidateCommand = ..., + validatecommand: tk._EntryValidateCommand = ..., values: list[str] | tuple[str, ...] = ..., width: int = ..., - xscrollcommand: tkinter._XYScrollCommand = ..., + xscrollcommand: tk._XYScrollCommand = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def config(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -338,34 +338,34 @@ class Frame(Widget): # (all of these keyword-only arguments are also present there) def __init__( self, - master: tkinter.Misc | None = None, + master: tk.Misc | None = None, *, - border: tkinter._ScreenUnits = ..., - borderwidth: tkinter._ScreenUnits = ..., + border: tk._ScreenUnits = ..., + borderwidth: tk._ScreenUnits = ..., class_: str = "", - cursor: tkinter._Cursor = "", - height: tkinter._ScreenUnits = 0, + cursor: tk._Cursor = "", + height: tk._ScreenUnits = 0, name: str = ..., padding: _Padding = ..., - relief: tkinter._Relief = ..., + relief: tk._Relief = ..., style: str = "", - takefocus: tkinter._TakeFocusValue = "", - width: tkinter._ScreenUnits = 0, + takefocus: tk._TakeFocusValue = "", + width: tk._ScreenUnits = 0, ) -> None: ... @overload def configure( self, cnf: dict[str, Any] | None = None, *, - border: tkinter._ScreenUnits = ..., - borderwidth: tkinter._ScreenUnits = ..., - cursor: tkinter._Cursor = ..., - height: tkinter._ScreenUnits = ..., + border: tk._ScreenUnits = ..., + borderwidth: tk._ScreenUnits = ..., + cursor: tk._Cursor = ..., + height: tk._ScreenUnits = ..., padding: _Padding = ..., - relief: tkinter._Relief = ..., + relief: tk._Relief = ..., style: str = ..., - takefocus: tkinter._TakeFocusValue = ..., - width: tkinter._ScreenUnits = ..., + takefocus: tk._TakeFocusValue = ..., + width: tk._ScreenUnits = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -374,56 +374,56 @@ class Frame(Widget): class Label(Widget): def __init__( self, - master: tkinter.Misc | None = None, + master: tk.Misc | None = None, *, - anchor: tkinter._Anchor = ..., + anchor: tk._Anchor = ..., background: str = "", - border: tkinter._ScreenUnits = ..., # alias for borderwidth - borderwidth: tkinter._ScreenUnits = ..., # undocumented + border: tk._ScreenUnits = ..., # alias for borderwidth + borderwidth: tk._ScreenUnits = ..., # undocumented class_: str = "", compound: _TtkCompound = "", - cursor: tkinter._Cursor = "", + cursor: tk._Cursor = "", font: _FontDescription = ..., foreground: str = "", - image: tkinter._ImageSpec = "", + image: tk._ImageSpec = "", justify: Literal["left", "center", "right"] = ..., name: str = ..., padding: _Padding = ..., - relief: tkinter._Relief = ..., + relief: tk._Relief = ..., state: str = "normal", style: str = "", - takefocus: tkinter._TakeFocusValue = "", + takefocus: tk._TakeFocusValue = "", text: float | str = "", - textvariable: tkinter.Variable = ..., + textvariable: tk.Variable = ..., underline: int = -1, width: int | Literal[""] = "", - wraplength: tkinter._ScreenUnits = ..., + wraplength: tk._ScreenUnits = ..., ) -> None: ... @overload def configure( self, cnf: dict[str, Any] | None = None, *, - anchor: tkinter._Anchor = ..., + anchor: tk._Anchor = ..., background: str = ..., - border: tkinter._ScreenUnits = ..., - borderwidth: tkinter._ScreenUnits = ..., + border: tk._ScreenUnits = ..., + borderwidth: tk._ScreenUnits = ..., compound: _TtkCompound = ..., - cursor: tkinter._Cursor = ..., + cursor: tk._Cursor = ..., font: _FontDescription = ..., foreground: str = ..., - image: tkinter._ImageSpec = ..., + image: tk._ImageSpec = ..., justify: Literal["left", "center", "right"] = ..., padding: _Padding = ..., - relief: tkinter._Relief = ..., + relief: tk._Relief = ..., state: str = ..., style: str = ..., - takefocus: tkinter._TakeFocusValue = ..., + takefocus: tk._TakeFocusValue = ..., text: float | str = ..., - textvariable: tkinter.Variable = ..., + textvariable: tk.Variable = ..., underline: int = ..., width: int | Literal[""] = ..., - wraplength: tkinter._ScreenUnits = ..., + wraplength: tk._ScreenUnits = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -432,42 +432,42 @@ class Label(Widget): class Labelframe(Widget): def __init__( self, - master: tkinter.Misc | None = None, + master: tk.Misc | None = None, *, - border: tkinter._ScreenUnits = ..., - borderwidth: tkinter._ScreenUnits = ..., # undocumented + border: tk._ScreenUnits = ..., + borderwidth: tk._ScreenUnits = ..., # undocumented class_: str = "", - cursor: tkinter._Cursor = "", - height: tkinter._ScreenUnits = 0, + cursor: tk._Cursor = "", + height: tk._ScreenUnits = 0, labelanchor: Literal["nw", "n", "ne", "en", "e", "es", "se", "s", "sw", "ws", "w", "wn"] = ..., - labelwidget: tkinter.Misc = ..., + labelwidget: tk.Misc = ..., name: str = ..., padding: _Padding = ..., - relief: tkinter._Relief = ..., # undocumented + relief: tk._Relief = ..., # undocumented style: str = "", - takefocus: tkinter._TakeFocusValue = "", + takefocus: tk._TakeFocusValue = "", text: float | str = "", underline: int = -1, - width: tkinter._ScreenUnits = 0, + width: tk._ScreenUnits = 0, ) -> None: ... @overload def configure( self, cnf: dict[str, Any] | None = None, *, - border: tkinter._ScreenUnits = ..., - borderwidth: tkinter._ScreenUnits = ..., - cursor: tkinter._Cursor = ..., - height: tkinter._ScreenUnits = ..., + border: tk._ScreenUnits = ..., + borderwidth: tk._ScreenUnits = ..., + cursor: tk._Cursor = ..., + height: tk._ScreenUnits = ..., labelanchor: Literal["nw", "n", "ne", "en", "e", "es", "se", "s", "sw", "ws", "w", "wn"] = ..., - labelwidget: tkinter.Misc = ..., + labelwidget: tk.Misc = ..., padding: _Padding = ..., - relief: tkinter._Relief = ..., + relief: tk._Relief = ..., style: str = ..., - takefocus: tkinter._TakeFocusValue = ..., + takefocus: tk._TakeFocusValue = ..., text: float | str = ..., underline: int = ..., - width: tkinter._ScreenUnits = ..., + width: tk._ScreenUnits = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -478,21 +478,21 @@ LabelFrame = Labelframe class Menubutton(Widget): def __init__( self, - master: tkinter.Misc | None = None, + master: tk.Misc | None = None, *, class_: str = "", compound: _TtkCompound = "", - cursor: tkinter._Cursor = "", + cursor: tk._Cursor = "", direction: Literal["above", "below", "left", "right", "flush"] = "below", - image: tkinter._ImageSpec = "", - menu: tkinter.Menu = ..., + image: tk._ImageSpec = "", + menu: tk.Menu = ..., name: str = ..., padding=..., # undocumented state: str = "normal", style: str = "", - takefocus: tkinter._TakeFocusValue = ..., + takefocus: tk._TakeFocusValue = ..., text: float | str = "", - textvariable: tkinter.Variable = ..., + textvariable: tk.Variable = ..., underline: int = -1, width: int | Literal[""] = "", ) -> None: ... @@ -502,16 +502,16 @@ class Menubutton(Widget): cnf: dict[str, Any] | None = None, *, compound: _TtkCompound = ..., - cursor: tkinter._Cursor = ..., + cursor: tk._Cursor = ..., direction: Literal["above", "below", "left", "right", "flush"] = ..., - image: tkinter._ImageSpec = ..., - menu: tkinter.Menu = ..., + image: tk._ImageSpec = ..., + menu: tk.Menu = ..., padding=..., state: str = ..., style: str = ..., - takefocus: tkinter._TakeFocusValue = ..., + takefocus: tk._TakeFocusValue = ..., text: float | str = ..., - textvariable: tkinter.Variable = ..., + textvariable: tk.Variable = ..., underline: int = ..., width: int | Literal[""] = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @@ -522,15 +522,15 @@ class Menubutton(Widget): class Notebook(Widget): def __init__( self, - master: tkinter.Misc | None = None, + master: tk.Misc | None = None, *, class_: str = "", - cursor: tkinter._Cursor = "", + cursor: tk._Cursor = "", height: int = 0, name: str = ..., padding: _Padding = ..., style: str = "", - takefocus: tkinter._TakeFocusValue = ..., + takefocus: tk._TakeFocusValue = ..., width: int = 0, ) -> None: ... @overload @@ -538,11 +538,11 @@ class Notebook(Widget): self, cnf: dict[str, Any] | None = None, *, - cursor: tkinter._Cursor = ..., + cursor: tk._Cursor = ..., height: int = ..., padding: _Padding = ..., style: str = ..., - takefocus: tkinter._TakeFocusValue = ..., + takefocus: tk._TakeFocusValue = ..., width: int = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload @@ -550,7 +550,7 @@ class Notebook(Widget): config = configure def add( self, - child: tkinter.Widget, + child: tk.Widget, *, state: Literal["normal", "disabled", "hidden"] = ..., sticky: str = ..., # consists of letters 'n', 's', 'w', 'e', no repeats, may be empty @@ -559,7 +559,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: tk._Compound = ..., underline: int = ..., ) -> None: ... def forget(self, tab_id) -> None: ... @@ -572,31 +572,31 @@ class Notebook(Widget): def tabs(self): ... def enable_traversal(self) -> None: ... -class Panedwindow(Widget, tkinter.PanedWindow): +class Panedwindow(Widget, tk.PanedWindow): def __init__( self, - master: tkinter.Misc | None = None, + master: tk.Misc | None = None, *, class_: str = "", - cursor: tkinter._Cursor = "", + cursor: tk._Cursor = "", # width and height for tkinter.ttk.Panedwindow are int but for tkinter.PanedWindow they are screen units height: int = 0, name: str = ..., orient: Literal["vertical", "horizontal"] = "vertical", # can't be changed with configure() style: str = "", - takefocus: tkinter._TakeFocusValue = "", + takefocus: tk._TakeFocusValue = "", width: int = 0, ) -> None: ... - def add(self, child: tkinter.Widget, *, weight: int = ..., **kw) -> None: ... + def add(self, child: tk.Widget, *, weight: int = ..., **kw) -> None: ... @overload # type: ignore[override] def configure( self, cnf: dict[str, Any] | None = None, *, - cursor: tkinter._Cursor = ..., + cursor: tk._Cursor = ..., height: int = ..., style: str = ..., - takefocus: tkinter._TakeFocusValue = ..., + takefocus: tk._TakeFocusValue = ..., width: int = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload @@ -607,10 +607,10 @@ class Panedwindow(Widget, tkinter.PanedWindow): self, cnf: dict[str, Any] | None = None, *, - cursor: tkinter._Cursor = ..., + cursor: tk._Cursor = ..., height: int = ..., style: str = ..., - takefocus: tkinter._TakeFocusValue = ..., + takefocus: tk._TakeFocusValue = ..., width: int = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload @@ -625,36 +625,36 @@ PanedWindow = Panedwindow class Progressbar(Widget): def __init__( self, - master: tkinter.Misc | None = None, + master: tk.Misc | None = None, *, class_: str = "", - cursor: tkinter._Cursor = "", - length: tkinter._ScreenUnits = 100, + cursor: tk._Cursor = "", + length: tk._ScreenUnits = 100, maximum: float = 100, mode: Literal["determinate", "indeterminate"] = "determinate", name: str = ..., orient: Literal["horizontal", "vertical"] = "horizontal", phase: int = 0, # docs say read-only but assigning int to this works style: str = "", - takefocus: tkinter._TakeFocusValue = "", + takefocus: tk._TakeFocusValue = "", value: float = 0.0, - variable: tkinter.IntVar | tkinter.DoubleVar = ..., + variable: tk.IntVar | tk.DoubleVar = ..., ) -> None: ... @overload def configure( self, cnf: dict[str, Any] | None = None, *, - cursor: tkinter._Cursor = ..., - length: tkinter._ScreenUnits = ..., + cursor: tk._Cursor = ..., + length: tk._ScreenUnits = ..., maximum: float = ..., mode: Literal["determinate", "indeterminate"] = ..., orient: Literal["horizontal", "vertical"] = ..., phase: int = ..., style: str = ..., - takefocus: tkinter._TakeFocusValue = ..., + takefocus: tk._TakeFocusValue = ..., value: float = ..., - variable: tkinter.IntVar | tkinter.DoubleVar = ..., + variable: tk.IntVar | tk.DoubleVar = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -666,23 +666,23 @@ class Progressbar(Widget): class Radiobutton(Widget): def __init__( self, - master: tkinter.Misc | None = None, + master: tk.Misc | None = None, *, class_: str = "", - command: tkinter._ButtonCommand = "", + command: tk._ButtonCommand = "", compound: _TtkCompound = "", - cursor: tkinter._Cursor = "", - image: tkinter._ImageSpec = "", + cursor: tk._Cursor = "", + image: tk._ImageSpec = "", name: str = ..., padding=..., # undocumented state: str = "normal", style: str = "", - takefocus: tkinter._TakeFocusValue = ..., + takefocus: tk._TakeFocusValue = ..., text: float | str = "", - textvariable: tkinter.Variable = ..., + textvariable: tk.Variable = ..., underline: int = -1, value: Any = "1", - variable: tkinter.Variable | Literal[""] = ..., + variable: tk.Variable | Literal[""] = ..., width: int | Literal[""] = "", ) -> None: ... @overload @@ -690,19 +690,19 @@ class Radiobutton(Widget): self, cnf: dict[str, Any] | None = None, *, - command: tkinter._ButtonCommand = ..., + command: tk._ButtonCommand = ..., compound: _TtkCompound = ..., - cursor: tkinter._Cursor = ..., - image: tkinter._ImageSpec = ..., + cursor: tk._Cursor = ..., + image: tk._ImageSpec = ..., padding=..., state: str = ..., style: str = ..., - takefocus: tkinter._TakeFocusValue = ..., + takefocus: tk._TakeFocusValue = ..., text: float | str = ..., - textvariable: tkinter.Variable = ..., + textvariable: tk.Variable = ..., underline: int = ..., value: Any = ..., - variable: tkinter.Variable | Literal[""] = ..., + variable: tk.Variable | Literal[""] = ..., width: int | Literal[""] = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload @@ -711,24 +711,24 @@ class Radiobutton(Widget): def invoke(self) -> Any: ... # type ignore, because identify() methods of Widget and tkinter.Scale are incompatible -class Scale(Widget, tkinter.Scale): # type: ignore[misc] +class Scale(Widget, tk.Scale): # type: ignore[misc] def __init__( self, - master: tkinter.Misc | None = None, + master: tk.Misc | None = None, *, class_: str = "", command: str | Callable[[str], object] = "", - cursor: tkinter._Cursor = "", + cursor: tk._Cursor = "", from_: float = 0, - length: tkinter._ScreenUnits = 100, + length: tk._ScreenUnits = 100, name: str = ..., orient: Literal["horizontal", "vertical"] = "horizontal", state: str = ..., # undocumented style: str = "", - takefocus: tkinter._TakeFocusValue = ..., + takefocus: tk._TakeFocusValue = ..., to: float = 1.0, value: float = 0, - variable: tkinter.IntVar | tkinter.DoubleVar = ..., + variable: tk.IntVar | tk.DoubleVar = ..., ) -> None: ... @overload # type: ignore[override] def configure( @@ -736,16 +736,16 @@ class Scale(Widget, tkinter.Scale): # type: ignore[misc] cnf: dict[str, Any] | None = None, *, command: str | Callable[[str], object] = ..., - cursor: tkinter._Cursor = ..., + cursor: tk._Cursor = ..., from_: float = ..., - length: tkinter._ScreenUnits = ..., + length: tk._ScreenUnits = ..., orient: Literal["horizontal", "vertical"] = ..., state: str = ..., style: str = ..., - takefocus: tkinter._TakeFocusValue = ..., + takefocus: tk._TakeFocusValue = ..., to: float = ..., value: float = ..., - variable: tkinter.IntVar | tkinter.DoubleVar = ..., + variable: tk.IntVar | tk.DoubleVar = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -756,34 +756,34 @@ class Scale(Widget, tkinter.Scale): # type: ignore[misc] cnf: dict[str, Any] | None = None, *, command: str | Callable[[str], object] = ..., - cursor: tkinter._Cursor = ..., + cursor: tk._Cursor = ..., from_: float = ..., - length: tkinter._ScreenUnits = ..., + length: tk._ScreenUnits = ..., orient: Literal["horizontal", "vertical"] = ..., state: str = ..., style: str = ..., - takefocus: tkinter._TakeFocusValue = ..., + takefocus: tk._TakeFocusValue = ..., to: float = ..., value: float = ..., - variable: tkinter.IntVar | tkinter.DoubleVar = ..., + variable: tk.IntVar | tk.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: int | None = None, y: int | None = None) -> float: ... # type ignore, because identify() methods of Widget and tkinter.Scale are incompatible -class Scrollbar(Widget, tkinter.Scrollbar): # type: ignore[misc] +class Scrollbar(Widget, tk.Scrollbar): # type: ignore[misc] def __init__( self, - master: tkinter.Misc | None = None, + master: tk.Misc | None = None, *, class_: str = "", command: Callable[..., tuple[float, float] | None] | str = "", - cursor: tkinter._Cursor = "", + cursor: tk._Cursor = "", name: str = ..., orient: Literal["horizontal", "vertical"] = "vertical", style: str = "", - takefocus: tkinter._TakeFocusValue = "", + takefocus: tk._TakeFocusValue = "", ) -> None: ... @overload # type: ignore[override] def configure( @@ -791,10 +791,10 @@ class Scrollbar(Widget, tkinter.Scrollbar): # type: ignore[misc] cnf: dict[str, Any] | None = None, *, command: Callable[..., tuple[float, float] | None] | str = ..., - cursor: tkinter._Cursor = ..., + cursor: tk._Cursor = ..., orient: Literal["horizontal", "vertical"] = ..., style: str = ..., - takefocus: tkinter._TakeFocusValue = ..., + takefocus: tk._TakeFocusValue = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -805,10 +805,10 @@ class Scrollbar(Widget, tkinter.Scrollbar): # type: ignore[misc] cnf: dict[str, Any] | None = None, *, command: Callable[..., tuple[float, float] | None] | str = ..., - cursor: tkinter._Cursor = ..., + cursor: tk._Cursor = ..., orient: Literal["horizontal", "vertical"] = ..., style: str = ..., - takefocus: tkinter._TakeFocusValue = ..., + takefocus: tk._TakeFocusValue = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def config(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -816,24 +816,24 @@ class Scrollbar(Widget, tkinter.Scrollbar): # type: ignore[misc] class Separator(Widget): def __init__( self, - master: tkinter.Misc | None = None, + master: tk.Misc | None = None, *, class_: str = "", - cursor: tkinter._Cursor = "", + cursor: tk._Cursor = "", name: str = ..., orient: Literal["horizontal", "vertical"] = "horizontal", style: str = "", - takefocus: tkinter._TakeFocusValue = "", + takefocus: tk._TakeFocusValue = "", ) -> None: ... @overload def configure( self, cnf: dict[str, Any] | None = None, *, - cursor: tkinter._Cursor = ..., + cursor: tk._Cursor = ..., orient: Literal["horizontal", "vertical"] = ..., style: str = ..., - takefocus: tkinter._TakeFocusValue = ..., + takefocus: tk._TakeFocusValue = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -842,22 +842,22 @@ class Separator(Widget): class Sizegrip(Widget): def __init__( self, - master: tkinter.Misc | None = None, + master: tk.Misc | None = None, *, class_: str = "", - cursor: tkinter._Cursor = ..., + cursor: tk._Cursor = ..., name: str = ..., style: str = "", - takefocus: tkinter._TakeFocusValue = "", + takefocus: tk._TakeFocusValue = "", ) -> None: ... @overload def configure( self, cnf: dict[str, Any] | None = None, *, - cursor: tkinter._Cursor = ..., + cursor: tk._Cursor = ..., style: str = ..., - takefocus: tkinter._TakeFocusValue = ..., + takefocus: tk._TakeFocusValue = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -866,33 +866,33 @@ class Sizegrip(Widget): class Spinbox(Entry): def __init__( self, - master: tkinter.Misc | None = None, + master: tk.Misc | None = None, *, background: str = ..., # undocumented class_: str = "", command: Callable[[], object] | str | list[str] | tuple[str, ...] = "", - cursor: tkinter._Cursor = "", + cursor: tk._Cursor = "", exportselection: bool = ..., # undocumented font: _FontDescription = ..., # undocumented foreground: str = ..., # undocumented format: str = "", from_: float = 0, increment: float = 1, - invalidcommand: tkinter._EntryValidateCommand = ..., # undocumented + invalidcommand: tk._EntryValidateCommand = ..., # undocumented justify: Literal["left", "center", "right"] = ..., # undocumented name: str = ..., show=..., # undocumented state: str = "normal", style: str = "", - takefocus: tkinter._TakeFocusValue = ..., - textvariable: tkinter.Variable = ..., # undocumented + takefocus: tk._TakeFocusValue = ..., + textvariable: tk.Variable = ..., # undocumented to: float = 0, validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = "none", - validatecommand: tkinter._EntryValidateCommand = "", + validatecommand: tk._EntryValidateCommand = "", values: list[str] | tuple[str, ...] = ..., width: int = ..., # undocumented wrap: bool = False, - xscrollcommand: tkinter._XYScrollCommand = "", + xscrollcommand: tk._XYScrollCommand = "", ) -> None: ... @overload # type: ignore[override] def configure( @@ -901,27 +901,27 @@ class Spinbox(Entry): *, background: str = ..., command: Callable[[], object] | str | list[str] | tuple[str, ...] = ..., - cursor: tkinter._Cursor = ..., + cursor: tk._Cursor = ..., exportselection: bool = ..., font: _FontDescription = ..., foreground: str = ..., format: str = ..., from_: float = ..., increment: float = ..., - invalidcommand: tkinter._EntryValidateCommand = ..., + invalidcommand: tk._EntryValidateCommand = ..., justify: Literal["left", "center", "right"] = ..., show=..., state: str = ..., style: str = ..., - takefocus: tkinter._TakeFocusValue = ..., - textvariable: tkinter.Variable = ..., + takefocus: tk._TakeFocusValue = ..., + textvariable: tk.Variable = ..., to: float = ..., validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., - validatecommand: tkinter._EntryValidateCommand = ..., + validatecommand: tk._EntryValidateCommand = ..., values: list[str] | tuple[str, ...] = ..., width: int = ..., wrap: bool = ..., - xscrollcommand: tkinter._XYScrollCommand = ..., + xscrollcommand: tk._XYScrollCommand = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -945,7 +945,7 @@ class _TreeviewTagDict(TypedDict): class _TreeviewHeaderDict(TypedDict): text: str image: list[str] | Literal[""] - anchor: tkinter._Anchor + anchor: tk._Anchor command: str state: str # Doesn't seem to appear anywhere else than in these dicts @@ -953,17 +953,17 @@ class _TreeviewColumnDict(TypedDict): width: int minwidth: int stretch: bool # actually 0 or 1 - anchor: tkinter._Anchor + anchor: tk._Anchor id: str -class Treeview(Widget, tkinter.XView, tkinter.YView): +class Treeview(Widget, tk.XView, tk.YView): def __init__( self, - master: tkinter.Misc | None = None, + master: tk.Misc | None = None, *, class_: str = "", columns: str | list[str] | list[int] | list[str | int] | tuple[str | int, ...] = "", - cursor: tkinter._Cursor = "", + cursor: tk._Cursor = "", displaycolumns: str | int | list[str] | tuple[str, ...] | list[int] | tuple[int, ...] = ("#all",), height: int = 10, name: str = ..., @@ -975,9 +975,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: tk._TakeFocusValue = ..., + xscrollcommand: tk._XYScrollCommand = "", + yscrollcommand: tk._XYScrollCommand = "", ) -> None: ... @overload def configure( @@ -985,16 +985,16 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): cnf: dict[str, Any] | None = None, *, columns: str | list[str] | list[int] | list[str | int] | tuple[str | int, ...] = ..., - cursor: tkinter._Cursor = ..., + cursor: tk._Cursor = ..., displaycolumns: str | int | list[str] | tuple[str, ...] | list[int] | tuple[int, ...] = ..., height: int = ..., padding: _Padding = ..., 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: tk._TakeFocusValue = ..., + xscrollcommand: tk._XYScrollCommand = ..., + yscrollcommand: tk._XYScrollCommand = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -1021,7 +1021,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): width: int = ..., minwidth: int = ..., stretch: bool = ..., - anchor: tkinter._Anchor = ..., + anchor: tk._Anchor = ..., # id is read-only ) -> _TreeviewColumnDict | None: ... def delete(self, *items: str | int) -> None: ... @@ -1050,8 +1050,8 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): option: None = None, *, text: str = ..., - image: tkinter._ImageSpec = ..., - anchor: tkinter._Anchor = ..., + image: tk._ImageSpec = ..., + anchor: tk._Anchor = ..., command: str | Callable[[], object] = ..., ) -> None: ... # Internal Method. Leave untyped: @@ -1069,7 +1069,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): *, id: str | int = ..., # same as iid text: str = ..., - image: tkinter._ImageSpec = ..., + image: tk._ImageSpec = ..., values: list[Any] | tuple[Any, ...] = ..., open: bool = ..., tags: str | list[str] | tuple[str, ...] = ..., @@ -1095,7 +1095,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): option: None = None, *, text: str = ..., - image: tkinter._ImageSpec = ..., + image: tk._ImageSpec = ..., values: list[Any] | tuple[Any, ...] | Literal[""] = ..., open: bool = ..., tags: str | list[str] | tuple[str, ...] = ..., @@ -1133,7 +1133,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): # Also, it's 'callback' instead of 'func' here. @overload def tag_bind( - self, tagname: str, sequence: str | None = None, callback: Callable[[tkinter.Event[Treeview]], object] | None = None + self, tagname: str, sequence: str | None = None, callback: Callable[[tk.Event[Treeview]], object] | None = None ) -> str: ... @overload def tag_bind(self, tagname: str, sequence: str | None, callback: str) -> None: ... @@ -1155,7 +1155,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): foreground: str = ..., background: str = ..., font: _FontDescription = ..., - image: tkinter._ImageSpec = ..., + image: tk._ImageSpec = ..., ) -> _TreeviewTagDict | MaybeNone: ... # can be None but annoying to check @overload def tag_has(self, tagname: str, item: None = None) -> tuple[str, ...]: ... @@ -1169,23 +1169,23 @@ class LabeledScale(Frame): # (all the keyword-only args except compound are from there) def __init__( self, - master: tkinter.Misc | None = None, - variable: tkinter.IntVar | tkinter.DoubleVar | None = None, + master: tk.Misc | None = None, + variable: tk.IntVar | tk.DoubleVar | None = None, from_: float = 0, to: float = 10, *, - border: tkinter._ScreenUnits = ..., - borderwidth: tkinter._ScreenUnits = ..., + border: tk._ScreenUnits = ..., + borderwidth: tk._ScreenUnits = ..., class_: str = "", compound: Literal["top", "bottom"] = "top", - cursor: tkinter._Cursor = "", - height: tkinter._ScreenUnits = 0, + cursor: tk._Cursor = "", + height: tk._ScreenUnits = 0, name: str = ..., padding: _Padding = ..., - relief: tkinter._Relief = ..., + relief: tk._Relief = ..., style: str = "", - takefocus: tkinter._TakeFocusValue = "", - width: tkinter._ScreenUnits = 0, + takefocus: tk._TakeFocusValue = "", + width: tk._ScreenUnits = 0, ) -> None: ... # destroy is overridden, signature does not change value: Any @@ -1193,14 +1193,14 @@ class LabeledScale(Frame): class OptionMenu(Menubutton): def __init__( self, - master: tkinter.Misc | None, - variable: tkinter.StringVar, + master: tk.Misc | None, + variable: tk.StringVar, default: str | None = None, *values: str, # rest of these are keyword-only because *args syntax used above style: str = "", direction: Literal["above", "below", "left", "right", "flush"] = "below", - command: Callable[[tkinter.StringVar], object] | None = None, + command: Callable[[tk.StringVar], object] | None = None, ) -> None: ... # configure, config, cget, destroy are inherited from Menubutton # destroy and __setitem__ are overridden, signature does not change diff --git a/stubs/JACK-Client/jack/__init__.pyi b/stubs/JACK-Client/jack/__init__.pyi index 4f8d61bd4de0..7d567460b8ca 100644 --- a/stubs/JACK-Client/jack/__init__.pyi +++ b/stubs/JACK-Client/jack/__init__.pyi @@ -4,7 +4,7 @@ from collections.abc import Callable, Generator, Iterable, Iterator, Sequence from typing import Any, Literal, NoReturn, overload from typing_extensions import Self -import numpy +import numpy as np from _cffi_backend import _CDataBase from numpy.typing import NDArray @@ -224,7 +224,7 @@ class OwnPort(Port): def disconnect(self, other: str | Port | None = None) -> None: ... def unregister(self) -> None: ... def get_buffer(self) -> _CBufferType: ... - def get_array(self) -> NDArray[numpy.float32]: ... + def get_array(self) -> NDArray[np.float32]: ... class OwnMidiPort(MidiPort, OwnPort): def __init__(self, port_ptr: _CDataBase, client: Client) -> None: ... diff --git a/stubs/networkx/networkx/classes/graph.pyi b/stubs/networkx/networkx/classes/graph.pyi index 981d61fd0b34..02c74eafc35e 100644 --- a/stubs/networkx/networkx/classes/graph.pyi +++ b/stubs/networkx/networkx/classes/graph.pyi @@ -4,7 +4,7 @@ from functools import cached_property from typing import Any, ClassVar, TypeVar, overload from typing_extensions import Self, TypeAlias -import numpy +import numpy as np from networkx.classes.coreviews import AdjacencyView, AtlasView from networkx.classes.digraph import DiGraph from networkx.classes.reportviews import DiDegreeView, NodeView, OutEdgeView @@ -22,7 +22,7 @@ _Data: TypeAlias = ( | dict[_Node, dict[_Node, dict[str, Any]]] | dict[_Node, Iterable[_Node]] | Iterable[_EdgePlus[_Node]] - | numpy.ndarray[Any, Any] + | np.ndarray[Any, Any] # | scipy.sparse.base.spmatrix ) diff --git a/stubs/networkx/networkx/convert_matrix.pyi b/stubs/networkx/networkx/convert_matrix.pyi index a94e00e7ada8..b3bbd0c48d43 100644 --- a/stubs/networkx/networkx/convert_matrix.pyi +++ b/stubs/networkx/networkx/convert_matrix.pyi @@ -3,7 +3,7 @@ from collections.abc import Callable, Collection, Hashable, Iterable from typing import Literal, TypeVar, overload from typing_extensions import TypeAlias -import numpy +import numpy as np from networkx.classes.graph import Graph, _Node from networkx.utils.backends import _dispatchable @@ -21,8 +21,8 @@ _G = TypeVar("_G", bound=Graph[Hashable]) def to_pandas_adjacency( G: Graph[_Node], nodelist: _Axes[_Node] | None = None, - dtype: numpy.dtype[Incomplete] | None = None, - order: numpy._OrderCF = None, + dtype: np.dtype[Incomplete] | None = None, + order: np._OrderCF = None, multigraph_weight: Callable[[list[float]], float] = ..., weight: str = "weight", nonedge: float = 0.0, @@ -72,17 +72,17 @@ def from_pandas_edgelist( def to_numpy_array( G: Graph[_Node], nodelist: Collection[_Node] | None = None, - dtype: numpy.dtype[Incomplete] | None = None, - order: numpy._OrderCF = None, + dtype: np.dtype[Incomplete] | None = None, + order: np._OrderCF = None, multigraph_weight: Callable[[list[float]], float] = ..., weight: str = "weight", nonedge: float = 0.0, -) -> numpy.ndarray[Incomplete, numpy.dtype[Incomplete]]: ... +) -> np.ndarray[Incomplete, np.dtype[Incomplete]]: ... @overload def from_numpy_array( - A: numpy.ndarray[Incomplete, Incomplete], parallel_edges: bool = False, create_using: None = None + A: np.ndarray[Incomplete, Incomplete], parallel_edges: bool = False, create_using: None = None ) -> Graph[Incomplete]: ... @overload -def from_numpy_array(A: numpy.ndarray[Incomplete, Incomplete], parallel_edges: bool = False, *, create_using: type[_G]) -> _G: ... +def from_numpy_array(A: np.ndarray[Incomplete, Incomplete], parallel_edges: bool = False, *, create_using: type[_G]) -> _G: ... @overload -def from_numpy_array(A: numpy.ndarray[Incomplete, Incomplete], parallel_edges: bool, create_using: type[_G]) -> _G: ... +def from_numpy_array(A: np.ndarray[Incomplete, Incomplete], parallel_edges: bool, create_using: type[_G]) -> _G: ... diff --git a/stubs/networkx/networkx/drawing/layout.pyi b/stubs/networkx/networkx/drawing/layout.pyi index 8d5f3dd1d1e9..5e14928ccebe 100644 --- a/stubs/networkx/networkx/drawing/layout.pyi +++ b/stubs/networkx/networkx/drawing/layout.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete -import numpy +import numpy as np def random_layout(G, center: Incomplete | None = None, dim: int = 2, seed: Incomplete | None = None): ... def circular_layout(G, scale: float = 1, center: Incomplete | None = None, dim: int = 2): ... @@ -57,7 +57,7 @@ def arf_layout( dt: float = 0.001, max_iter: int = 1000, *, - seed: int | numpy.random.RandomState | None = None, + seed: int | np.random.RandomState | None = None, ): ... def rescale_layout(pos, scale: float = 1): ... def rescale_layout_dict(pos, scale: float = 1): ... diff --git a/stubs/networkx/networkx/utils/misc.pyi b/stubs/networkx/networkx/utils/misc.pyi index 261e030b1df2..ea09c775ef1d 100644 --- a/stubs/networkx/networkx/utils/misc.pyi +++ b/stubs/networkx/networkx/utils/misc.pyi @@ -3,7 +3,7 @@ from _typeshed import Incomplete from types import ModuleType from typing_extensions import TypeAlias -import numpy +import numpy as np __all__ = [ "flatten", @@ -23,7 +23,7 @@ __all__ = [ ] _RandomNumberGenerator: TypeAlias = ( - ModuleType | random.Random | numpy.random.RandomState | numpy.random.Generator | PythonRandomInterface + ModuleType | random.Random | np.random.RandomState | np.random.Generator | PythonRandomInterface ) _RandomState: TypeAlias = int | _RandomNumberGenerator | None @@ -36,7 +36,7 @@ def groups(many_to_one): ... def create_random_state(random_state: Incomplete | None = None): ... class PythonRandomViaNumpyBits(random.Random): - def __init__(self, rng: numpy.random.Generator | None = None) -> None: ... + def __init__(self, rng: np.random.Generator | None = None) -> None: ... def getrandbits(self, k: int) -> int: ... class PythonRandomInterface: diff --git a/stubs/tensorflow/tensorflow/_aliases.pyi b/stubs/tensorflow/tensorflow/_aliases.pyi index d8beae33eb11..ad55f7fd2e39 100644 --- a/stubs/tensorflow/tensorflow/_aliases.pyi +++ b/stubs/tensorflow/tensorflow/_aliases.pyi @@ -5,7 +5,7 @@ from collections.abc import Iterable, Mapping, Sequence from typing import Any, Protocol, TypeVar from typing_extensions import TypeAlias -import numpy # pytype needs the unaliased import to resolve DTypeLike +import numpy # noqa: ICN001 # pytype needs the unaliased import to resolve DTypeLike import numpy as np import numpy.typing as npt import tensorflow as tf diff --git a/stubs/ttkthemes/ttkthemes/themed_style.pyi b/stubs/ttkthemes/ttkthemes/themed_style.pyi index e880f0718dc2..0e46a4430101 100644 --- a/stubs/ttkthemes/ttkthemes/themed_style.pyi +++ b/stubs/ttkthemes/ttkthemes/themed_style.pyi @@ -1,11 +1,11 @@ -import tkinter +import tkinter as tk from tkinter import ttk from ._widget import ThemedWidget class ThemedStyle(ttk.Style, ThemedWidget): def __init__( - self, master: tkinter.Misc | None = ..., *, theme: str | None = ..., gif_override: bool | None = ..., **kwargs + self, master: tk.Misc | None = ..., *, theme: str | None = ..., gif_override: bool | None = ..., **kwargs ) -> None: ... # theme_use() can't return None (differs from ttk.Style) def theme_use(self, theme_name: str | None = None) -> str: ... # type: ignore[override] diff --git a/stubs/ttkthemes/ttkthemes/themed_tk.pyi b/stubs/ttkthemes/ttkthemes/themed_tk.pyi index 8bf6ac4c6e5f..b05d89e21c06 100644 --- a/stubs/ttkthemes/ttkthemes/themed_tk.pyi +++ b/stubs/ttkthemes/ttkthemes/themed_tk.pyi @@ -1,9 +1,9 @@ -import tkinter +import tkinter as tk from _typeshed import Incomplete from ._widget import ThemedWidget -class ThemedTk(tkinter.Tk, ThemedWidget): +class ThemedTk(tk.Tk, ThemedWidget): def __init__( self, # non-keyword-only args copied from tkinter.Tk From 32e1ba655e118b1afda06b106cc789ceb7a2d00e Mon Sep 17 00:00:00 2001 From: Avasam Date: Thu, 27 Mar 2025 19:13:13 -0400 Subject: [PATCH 2/4] Revert for tkinter --- pyproject.toml | 18 +- stdlib/tkinter/font.pyi | 32 +- stdlib/tkinter/tix.pyi | 104 ++--- stdlib/tkinter/ttk.pyi | 498 ++++++++++----------- stubs/ttkthemes/ttkthemes/themed_style.pyi | 4 +- stubs/ttkthemes/ttkthemes/themed_tk.pyi | 4 +- 6 files changed, 338 insertions(+), 322 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 440b85dc3cdf..e11f10c091b1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -205,7 +205,23 @@ ignore = [ [tool.ruff.lint.pydocstyle] convention = "pep257" # https://docs.astral.sh/ruff/settings/#lint_pydocstyle_convention -[tool.lint.flake8-import-conventions.extend-aliases] +[tool.ruff.lint.flake8-import-conventions.aliases] +# Same as default +"altair"="alt" +"matplotlib"="mpl" +"matplotlib.pyplot"="plt" +"numpy"="np" +"pandas"="pd" +"seaborn"="sns" +"tensorflow"="tf" +# "tkinter"="tk" # Causes issues with stubtest +"holoviews"="hv" +"panel"="pn" +"plotly.express"="px" +"polars"="pl" +"pyarrow"="pa" +"xml.etree.ElementTree"="ET" +# Added "numpy.typing" = "npt" [tool.ruff.lint.isort] diff --git a/stdlib/tkinter/font.pyi b/stdlib/tkinter/font.pyi index fd2df5474b10..3b73f982c4ca 100644 --- a/stdlib/tkinter/font.pyi +++ b/stdlib/tkinter/font.pyi @@ -1,7 +1,7 @@ import _tkinter import itertools import sys -import tkinter as tk +import tkinter from typing import Any, ClassVar, Final, Literal, TypedDict, overload from typing_extensions import TypeAlias, Unpack @@ -46,7 +46,7 @@ class Font: self, # In tkinter, 'root' refers to tkinter.Tk by convention, but the code # actually works with any tkinter widget so we use tkinter.Misc. - root: tk.Misc | None = None, + root: tkinter.Misc | None = None, font: _FontDescription | None = None, name: str | None = None, exists: bool = False, @@ -74,19 +74,19 @@ class Font: def cget(self, option: str) -> Any: ... __getitem__ = cget @overload - def actual(self, option: Literal["family"], displayof: tk.Misc | None = None) -> str: ... + def actual(self, option: Literal["family"], displayof: tkinter.Misc | None = None) -> str: ... @overload - def actual(self, option: Literal["size"], displayof: tk.Misc | None = None) -> int: ... + def actual(self, option: Literal["size"], displayof: tkinter.Misc | None = None) -> int: ... @overload - def actual(self, option: Literal["weight"], displayof: tk.Misc | None = None) -> Literal["normal", "bold"]: ... + def actual(self, option: Literal["weight"], displayof: tkinter.Misc | None = None) -> Literal["normal", "bold"]: ... @overload - def actual(self, option: Literal["slant"], displayof: tk.Misc | None = None) -> Literal["roman", "italic"]: ... + def actual(self, option: Literal["slant"], displayof: tkinter.Misc | None = None) -> Literal["roman", "italic"]: ... @overload - def actual(self, option: Literal["underline", "overstrike"], displayof: tk.Misc | None = None) -> bool: ... + def actual(self, option: Literal["underline", "overstrike"], displayof: tkinter.Misc | None = None) -> bool: ... @overload - def actual(self, option: None, displayof: tk.Misc | None = None) -> _FontDict: ... + def actual(self, option: None, displayof: tkinter.Misc | None = None) -> _FontDict: ... @overload - def actual(self, *, displayof: tk.Misc | None = None) -> _FontDict: ... + def actual(self, *, displayof: tkinter.Misc | None = None) -> _FontDict: ... def config( self, *, @@ -100,20 +100,20 @@ class Font: configure = config def copy(self) -> Font: ... @overload - def metrics(self, option: Literal["ascent", "descent", "linespace"], /, *, displayof: tk.Misc | None = ...) -> int: ... + def metrics(self, option: Literal["ascent", "descent", "linespace"], /, *, displayof: tkinter.Misc | None = ...) -> int: ... @overload - def metrics(self, option: Literal["fixed"], /, *, displayof: tk.Misc | None = ...) -> bool: ... + def metrics(self, option: Literal["fixed"], /, *, displayof: tkinter.Misc | None = ...) -> bool: ... @overload - def metrics(self, *, displayof: tk.Misc | None = ...) -> _MetricsDict: ... - def measure(self, text: str, displayof: tk.Misc | None = None) -> int: ... + def metrics(self, *, displayof: tkinter.Misc | None = ...) -> _MetricsDict: ... + def measure(self, text: str, displayof: tkinter.Misc | None = None) -> int: ... def __eq__(self, other: object) -> bool: ... def __del__(self) -> None: ... -def families(root: tk.Misc | None = None, displayof: tk.Misc | None = None) -> tuple[str, ...]: ... -def names(root: tk.Misc | None = None) -> tuple[str, ...]: ... +def families(root: tkinter.Misc | None = None, displayof: tkinter.Misc | None = None) -> tuple[str, ...]: ... +def names(root: tkinter.Misc | None = None) -> tuple[str, ...]: ... if sys.version_info >= (3, 10): - def nametofont(name: str, root: tk.Misc | None = None) -> Font: ... + def nametofont(name: str, root: tkinter.Misc | None = None) -> Font: ... else: def nametofont(name: str) -> Font: ... diff --git a/stdlib/tkinter/tix.pyi b/stdlib/tkinter/tix.pyi index 2aeb57544f8d..7891364fa02c 100644 --- a/stdlib/tkinter/tix.pyi +++ b/stdlib/tkinter/tix.pyi @@ -1,4 +1,4 @@ -import tkinter as tk +import tkinter from _typeshed import Incomplete from typing import Any, Final @@ -44,13 +44,13 @@ class tixCommand: def tix_option_get(self, name: str) -> Any: ... def tix_resetoptions(self, newScheme: str, newFontSet: str, newScmPrio: str | None = None) -> None: ... -class Tk(tk.Tk, tixCommand): +class Tk(tkinter.Tk, tixCommand): def __init__(self, screenName: str | None = None, baseName: str | None = None, className: str = "Tix") -> None: ... -class TixWidget(tk.Widget): +class TixWidget(tkinter.Widget): def __init__( self, - master: tk.Misc | None = None, + master: tkinter.Misc | None = None, widgetName: str | None = None, static_options: list[str] | None = None, cnf: dict[str, Any] = {}, @@ -58,56 +58,56 @@ class TixWidget(tk.Widget): ) -> None: ... def __getattr__(self, name: str): ... def set_silent(self, value: str) -> None: ... - def subwidget(self, name: str) -> tk.Widget: ... - def subwidgets_all(self) -> list[tk.Widget]: ... + def subwidget(self, name: str) -> tkinter.Widget: ... + def subwidgets_all(self) -> list[tkinter.Widget]: ... def config_all(self, option: Any, value: Any) -> None: ... - def image_create(self, imgtype: str, cnf: dict[str, Any] = {}, master: tk.Widget | None = None, **kw) -> None: ... + def image_create(self, imgtype: str, cnf: dict[str, Any] = {}, master: tkinter.Widget | None = None, **kw) -> None: ... def image_delete(self, imgname: str) -> None: ... class TixSubWidget(TixWidget): - def __init__(self, master: tk.Widget, name: str, destroy_physically: int = 1, check_intermediate: int = 1) -> None: ... + def __init__(self, master: tkinter.Widget, name: str, destroy_physically: int = 1, check_intermediate: int = 1) -> None: ... class DisplayStyle: - def __init__(self, itemtype: str, cnf: dict[str, Any] = {}, *, master: tk.Widget | None = None, **kw) -> None: ... + def __init__(self, itemtype: str, cnf: dict[str, Any] = {}, *, master: tkinter.Widget | None = None, **kw) -> None: ... def __getitem__(self, key: str): ... def __setitem__(self, key: str, value: Any) -> None: ... def delete(self) -> None: ... def config(self, cnf: dict[str, Any] = {}, **kw): ... class Balloon(TixWidget): - def __init__(self, master: tk.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... - def bind_widget(self, widget: tk.Widget, cnf: dict[str, Any] = {}, **kw) -> None: ... - def unbind_widget(self, widget: tk.Widget) -> None: ... + def __init__(self, master: tkinter.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def bind_widget(self, widget: tkinter.Widget, cnf: dict[str, Any] = {}, **kw) -> None: ... + def unbind_widget(self, widget: tkinter.Widget) -> None: ... class ButtonBox(TixWidget): - def __init__(self, master: tk.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... - def add(self, name: str, cnf: dict[str, Any] = {}, **kw) -> tk.Widget: ... + def __init__(self, master: tkinter.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def add(self, name: str, cnf: dict[str, Any] = {}, **kw) -> tkinter.Widget: ... def invoke(self, name: str) -> None: ... class ComboBox(TixWidget): - def __init__(self, master: tk.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tkinter.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... def add_history(self, str: str) -> None: ... def append_history(self, str: str) -> None: ... def insert(self, index: int, str: str) -> None: ... def pick(self, index: int) -> None: ... class Control(TixWidget): - def __init__(self, master: tk.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tkinter.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... def decrement(self) -> None: ... def increment(self) -> None: ... def invoke(self) -> None: ... class LabelEntry(TixWidget): - def __init__(self, master: tk.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tkinter.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... class LabelFrame(TixWidget): - def __init__(self, master: tk.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tkinter.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... class Meter(TixWidget): - def __init__(self, master: tk.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tkinter.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... class OptionMenu(TixWidget): - def __init__(self, master: tk.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... def add_command(self, name: str, cnf: dict[str, Any] = {}, **kw) -> None: ... def add_separator(self, name: str, cnf: dict[str, Any] = {}, **kw) -> None: ... def delete(self, name: str) -> None: ... @@ -115,55 +115,55 @@ class OptionMenu(TixWidget): def enable(self, name: str) -> None: ... class PopupMenu(TixWidget): - def __init__(self, master: tk.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... - def bind_widget(self, widget: tk.Widget) -> None: ... - def unbind_widget(self, widget: tk.Widget) -> None: ... - def post_widget(self, widget: tk.Widget, x: int, y: int) -> None: ... + def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def bind_widget(self, widget: tkinter.Widget) -> None: ... + def unbind_widget(self, widget: tkinter.Widget) -> None: ... + def post_widget(self, widget: tkinter.Widget, x: int, y: int) -> None: ... class Select(TixWidget): - def __init__(self, master: tk.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... - def add(self, name: str, cnf: dict[str, Any] = {}, **kw) -> tk.Widget: ... + def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def add(self, name: str, cnf: dict[str, Any] = {}, **kw) -> tkinter.Widget: ... def invoke(self, name: str) -> None: ... class StdButtonBox(TixWidget): - def __init__(self, master: tk.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tkinter.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... def invoke(self, name: str) -> None: ... class DirList(TixWidget): - def __init__(self, master: tk.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... def chdir(self, dir: str) -> None: ... class DirTree(TixWidget): - def __init__(self, master: tk.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... def chdir(self, dir: str) -> None: ... class DirSelectDialog(TixWidget): - def __init__(self, master: tk.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... def popup(self) -> None: ... def popdown(self) -> None: ... class DirSelectBox(TixWidget): - def __init__(self, master: tk.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... class ExFileSelectBox(TixWidget): - def __init__(self, master: tk.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... def filter(self) -> None: ... def invoke(self) -> None: ... class FileSelectBox(TixWidget): - def __init__(self, master: tk.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... def apply_filter(self) -> None: ... def invoke(self) -> None: ... class FileEntry(TixWidget): - def __init__(self, master: tk.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... def invoke(self) -> None: ... def file_dialog(self) -> None: ... -class HList(TixWidget, tk.XView, tk.YView): - def __init__(self, master: tk.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... - def add(self, entry: str, cnf: dict[str, Any] = {}, **kw) -> tk.Widget: ... - def add_child(self, parent: str | None = None, cnf: dict[str, Any] = {}, **kw) -> tk.Widget: ... +class HList(TixWidget, tkinter.XView, tkinter.YView): + def __init__(self, master: tkinter.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def add(self, entry: str, cnf: dict[str, Any] = {}, **kw) -> tkinter.Widget: ... + def add_child(self, parent: str | None = None, cnf: dict[str, Any] = {}, **kw) -> tkinter.Widget: ... def anchor_set(self, entry: str) -> None: ... def anchor_clear(self) -> None: ... # FIXME: Overload, certain combos return, others don't @@ -217,7 +217,7 @@ class HList(TixWidget, tk.XView, tk.YView): def show_entry(self, entry: str) -> None: ... class CheckList(TixWidget): - def __init__(self, master: tk.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tkinter.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... def autosetmode(self) -> None: ... def close(self, entrypath: str) -> None: ... def getmode(self, entrypath: str) -> str: ... @@ -227,15 +227,15 @@ class CheckList(TixWidget): def setstatus(self, entrypath: str, mode: str = "on") -> None: ... class Tree(TixWidget): - def __init__(self, master: tk.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tkinter.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... def autosetmode(self) -> None: ... def close(self, entrypath: str) -> None: ... def getmode(self, entrypath: str) -> str: ... def open(self, entrypath: str) -> None: ... def setmode(self, entrypath: str, mode: str = "none") -> None: ... -class TList(TixWidget, tk.XView, tk.YView): - def __init__(self, master: tk.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... +class TList(TixWidget, tkinter.XView, tkinter.YView): + def __init__(self, master: tkinter.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... def active_set(self, index: int) -> None: ... def active_clear(self) -> None: ... def anchor_set(self, index: int) -> None: ... @@ -261,32 +261,32 @@ class TList(TixWidget, tk.XView, tk.YView): def selection_set(self, first: int, last: int | None = None) -> None: ... class PanedWindow(TixWidget): - def __init__(self, master: tk.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... def add(self, name: str, cnf: dict[str, Any] = {}, **kw) -> None: ... def delete(self, name: str) -> None: ... def forget(self, name: str) -> None: ... # type: ignore[override] def panecget(self, entry: str, opt): ... def paneconfigure(self, entry: str, cnf: dict[str, Any] = {}, **kw) -> Incomplete | None: ... - def panes(self) -> list[tk.Widget]: ... + def panes(self) -> list[tkinter.Widget]: ... class ListNoteBook(TixWidget): - def __init__(self, master: tk.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tkinter.Widget | None, cnf: dict[str, Any] = {}, **kw) -> None: ... def add(self, name: str, cnf: dict[str, Any] = {}, **kw) -> None: ... - def page(self, name: str) -> tk.Widget: ... - def pages(self) -> list[tk.Widget]: ... + def page(self, name: str) -> tkinter.Widget: ... + def pages(self) -> list[tkinter.Widget]: ... def raise_page(self, name: str) -> None: ... class NoteBook(TixWidget): - def __init__(self, master: tk.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tkinter.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... def add(self, name: str, cnf: dict[str, Any] = {}, **kw) -> None: ... def delete(self, name: str) -> None: ... - def page(self, name: str) -> tk.Widget: ... - def pages(self) -> list[tk.Widget]: ... + def page(self, name: str) -> tkinter.Widget: ... + def pages(self) -> list[tkinter.Widget]: ... def raise_page(self, name: str) -> None: ... def raised(self) -> bool: ... class InputOnly(TixWidget): - def __init__(self, master: tk.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... + def __init__(self, master: tkinter.Widget | None = None, cnf: dict[str, Any] = {}, **kw) -> None: ... class Form: def __setitem__(self, key: str, value: Any) -> None: ... @@ -296,4 +296,4 @@ class Form: def forget(self) -> None: ... def grid(self, xsize: int = 0, ysize: int = 0) -> tuple[int, int] | None: ... def info(self, option: str | None = None): ... - def slaves(self) -> list[tk.Widget]: ... + def slaves(self) -> list[tkinter.Widget]: ... diff --git a/stdlib/tkinter/ttk.pyi b/stdlib/tkinter/ttk.pyi index eaf26badf024..5328e461ebdc 100644 --- a/stdlib/tkinter/ttk.pyi +++ b/stdlib/tkinter/ttk.pyi @@ -1,5 +1,5 @@ import _tkinter -import tkinter as tk +import tkinter from _typeshed import Incomplete, MaybeNone from collections.abc import Callable from tkinter.font import _FontDescription @@ -38,20 +38,20 @@ def tclobjs_to_py(adict: dict[Any, Any]) -> dict[Any, Any]: ... def setup_master(master: Incomplete | None = None): ... _Padding: TypeAlias = ( - tk._ScreenUnits - | tuple[tk._ScreenUnits] - | tuple[tk._ScreenUnits, tk._ScreenUnits] - | tuple[tk._ScreenUnits, tk._ScreenUnits, tk._ScreenUnits] - | tuple[tk._ScreenUnits, tk._ScreenUnits, tk._ScreenUnits, tk._ScreenUnits] + tkinter._ScreenUnits + | tuple[tkinter._ScreenUnits] + | tuple[tkinter._ScreenUnits, tkinter._ScreenUnits] + | tuple[tkinter._ScreenUnits, tkinter._ScreenUnits, tkinter._ScreenUnits] + | 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", tk._Compound] +_TtkCompound: TypeAlias = Literal["", "text", "image", tkinter._Compound] class Style: master: Incomplete tk: _tkinter.TkappType - def __init__(self, master: tk.Misc | None = None) -> None: ... + def __init__(self, master: tkinter.Misc | None = None) -> None: ... def configure(self, style, query_opt: Incomplete | None = None, **kw): ... def map(self, style, query_opt: Incomplete | None = None, **kw): ... def lookup(self, style, option, state: Incomplete | None = None, default: Incomplete | None = None): ... @@ -67,8 +67,8 @@ class Style: @overload def theme_use(self, themename: None = None) -> str: ... -class Widget(tk.Widget): - def __init__(self, master: tk.Misc | None, widgetname, kw: Incomplete | None = None) -> None: ... +class Widget(tkinter.Widget): + def __init__(self, master: tkinter.Misc | None, widgetname, kw: Incomplete | None = None) -> None: ... def identify(self, x: int, y: int) -> str: ... def instate(self, statespec, callback: Incomplete | None = None, *args, **kw): ... def state(self, statespec: Incomplete | None = None): ... @@ -76,21 +76,21 @@ class Widget(tk.Widget): class Button(Widget): def __init__( self, - master: tk.Misc | None = None, + master: tkinter.Misc | None = None, *, class_: str = "", - command: tk._ButtonCommand = "", + command: tkinter._ButtonCommand = "", compound: _TtkCompound = "", - cursor: tk._Cursor = "", + cursor: tkinter._Cursor = "", default: Literal["normal", "active", "disabled"] = "normal", - image: tk._ImageSpec = "", + image: tkinter._ImageSpec = "", name: str = ..., padding=..., # undocumented state: str = "normal", style: str = "", - takefocus: tk._TakeFocusValue = ..., + takefocus: tkinter._TakeFocusValue = ..., text: float | str = "", - textvariable: tk.Variable = ..., + textvariable: tkinter.Variable = ..., underline: int = -1, width: int | Literal[""] = "", ) -> None: ... @@ -99,17 +99,17 @@ class Button(Widget): self, cnf: dict[str, Any] | None = None, *, - command: tk._ButtonCommand = ..., + command: tkinter._ButtonCommand = ..., compound: _TtkCompound = ..., - cursor: tk._Cursor = ..., + cursor: tkinter._Cursor = ..., default: Literal["normal", "active", "disabled"] = ..., - image: tk._ImageSpec = ..., + image: tkinter._ImageSpec = ..., padding=..., state: str = ..., style: str = ..., - takefocus: tk._TakeFocusValue = ..., + takefocus: tkinter._TakeFocusValue = ..., text: float | str = ..., - textvariable: tk.Variable = ..., + textvariable: tkinter.Variable = ..., underline: int = ..., width: int | Literal[""] = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @@ -121,27 +121,27 @@ class Button(Widget): class Checkbutton(Widget): def __init__( self, - master: tk.Misc | None = None, + master: tkinter.Misc | None = None, *, class_: str = "", - command: tk._ButtonCommand = "", + command: tkinter._ButtonCommand = "", compound: _TtkCompound = "", - cursor: tk._Cursor = "", - image: tk._ImageSpec = "", + cursor: tkinter._Cursor = "", + image: tkinter._ImageSpec = "", name: str = ..., offvalue: Any = 0, onvalue: Any = 1, padding=..., # undocumented state: str = "normal", style: str = "", - takefocus: tk._TakeFocusValue = ..., + takefocus: tkinter._TakeFocusValue = ..., text: float | str = "", - textvariable: tk.Variable = ..., + textvariable: tkinter.Variable = ..., underline: int = -1, # 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: tk.Variable = ..., + variable: tkinter.Variable = ..., width: int | Literal[""] = "", ) -> None: ... @overload @@ -149,20 +149,20 @@ class Checkbutton(Widget): self, cnf: dict[str, Any] | None = None, *, - command: tk._ButtonCommand = ..., + command: tkinter._ButtonCommand = ..., compound: _TtkCompound = ..., - cursor: tk._Cursor = ..., - image: tk._ImageSpec = ..., + cursor: tkinter._Cursor = ..., + image: tkinter._ImageSpec = ..., offvalue: Any = ..., onvalue: Any = ..., padding=..., state: str = ..., style: str = ..., - takefocus: tk._TakeFocusValue = ..., + takefocus: tkinter._TakeFocusValue = ..., text: float | str = ..., - textvariable: tk.Variable = ..., + textvariable: tkinter.Variable = ..., underline: int = ..., - variable: tk.Variable = ..., + variable: tkinter.Variable = ..., width: int | Literal[""] = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload @@ -170,30 +170,30 @@ class Checkbutton(Widget): config = configure def invoke(self) -> Any: ... -class Entry(Widget, tk.Entry): +class Entry(Widget, tkinter.Entry): def __init__( self, - master: tk.Misc | None = None, + master: tkinter.Misc | None = None, widget: str | None = None, *, background: str = ..., # undocumented class_: str = "", - cursor: tk._Cursor = ..., + cursor: tkinter._Cursor = ..., exportselection: bool = True, font: _FontDescription = "TkTextFont", foreground: str = "", - invalidcommand: tk._EntryValidateCommand = "", + invalidcommand: tkinter._EntryValidateCommand = "", justify: Literal["left", "center", "right"] = "left", name: str = ..., show: str = "", state: str = "normal", style: str = "", - takefocus: tk._TakeFocusValue = ..., - textvariable: tk.Variable = ..., + takefocus: tkinter._TakeFocusValue = ..., + textvariable: tkinter.Variable = ..., validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = "none", - validatecommand: tk._EntryValidateCommand = "", + validatecommand: tkinter._EntryValidateCommand = "", width: int = 20, - xscrollcommand: tk._XYScrollCommand = "", + xscrollcommand: tkinter._XYScrollCommand = "", ) -> None: ... @overload # type: ignore[override] def configure( @@ -201,21 +201,21 @@ class Entry(Widget, tk.Entry): cnf: dict[str, Any] | None = None, *, background: str = ..., - cursor: tk._Cursor = ..., + cursor: tkinter._Cursor = ..., exportselection: bool = ..., font: _FontDescription = ..., foreground: str = ..., - invalidcommand: tk._EntryValidateCommand = ..., + invalidcommand: tkinter._EntryValidateCommand = ..., justify: Literal["left", "center", "right"] = ..., show: str = ..., state: str = ..., style: str = ..., - takefocus: tk._TakeFocusValue = ..., - textvariable: tk.Variable = ..., + takefocus: tkinter._TakeFocusValue = ..., + textvariable: tkinter.Variable = ..., validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., - validatecommand: tk._EntryValidateCommand = ..., + validatecommand: tkinter._EntryValidateCommand = ..., width: int = ..., - xscrollcommand: tk._XYScrollCommand = ..., + xscrollcommand: tkinter._XYScrollCommand = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -226,21 +226,21 @@ class Entry(Widget, tk.Entry): cnf: dict[str, Any] | None = None, *, background: str = ..., - cursor: tk._Cursor = ..., + cursor: tkinter._Cursor = ..., exportselection: bool = ..., font: _FontDescription = ..., foreground: str = ..., - invalidcommand: tk._EntryValidateCommand = ..., + invalidcommand: tkinter._EntryValidateCommand = ..., justify: Literal["left", "center", "right"] = ..., show: str = ..., state: str = ..., style: str = ..., - takefocus: tk._TakeFocusValue = ..., - textvariable: tk.Variable = ..., + takefocus: tkinter._TakeFocusValue = ..., + textvariable: tkinter.Variable = ..., validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., - validatecommand: tk._EntryValidateCommand = ..., + validatecommand: tkinter._EntryValidateCommand = ..., width: int = ..., - xscrollcommand: tk._XYScrollCommand = ..., + xscrollcommand: tkinter._XYScrollCommand = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def config(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -251,29 +251,29 @@ class Entry(Widget, tk.Entry): class Combobox(Entry): def __init__( self, - master: tk.Misc | None = None, + master: tkinter.Misc | None = None, *, background: str = ..., # undocumented class_: str = "", - cursor: tk._Cursor = "", + cursor: tkinter._Cursor = "", exportselection: bool = True, font: _FontDescription = ..., # undocumented foreground: str = ..., # undocumented height: int = 10, - invalidcommand: tk._EntryValidateCommand = ..., # undocumented + invalidcommand: tkinter._EntryValidateCommand = ..., # undocumented justify: Literal["left", "center", "right"] = "left", name: str = ..., postcommand: Callable[[], object] | str = "", show=..., # undocumented state: str = "normal", style: str = "", - takefocus: tk._TakeFocusValue = ..., - textvariable: tk.Variable = ..., + takefocus: tkinter._TakeFocusValue = ..., + textvariable: tkinter.Variable = ..., validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., # undocumented - validatecommand: tk._EntryValidateCommand = ..., # undocumented + validatecommand: tkinter._EntryValidateCommand = ..., # undocumented values: list[str] | tuple[str, ...] = ..., width: int = 20, - xscrollcommand: tk._XYScrollCommand = ..., # undocumented + xscrollcommand: tkinter._XYScrollCommand = ..., # undocumented ) -> None: ... @overload # type: ignore[override] def configure( @@ -281,24 +281,24 @@ class Combobox(Entry): cnf: dict[str, Any] | None = None, *, background: str = ..., - cursor: tk._Cursor = ..., + cursor: tkinter._Cursor = ..., exportselection: bool = ..., font: _FontDescription = ..., foreground: str = ..., height: int = ..., - invalidcommand: tk._EntryValidateCommand = ..., + invalidcommand: tkinter._EntryValidateCommand = ..., justify: Literal["left", "center", "right"] = ..., postcommand: Callable[[], object] | str = ..., show=..., state: str = ..., style: str = ..., - takefocus: tk._TakeFocusValue = ..., - textvariable: tk.Variable = ..., + takefocus: tkinter._TakeFocusValue = ..., + textvariable: tkinter.Variable = ..., validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., - validatecommand: tk._EntryValidateCommand = ..., + validatecommand: tkinter._EntryValidateCommand = ..., values: list[str] | tuple[str, ...] = ..., width: int = ..., - xscrollcommand: tk._XYScrollCommand = ..., + xscrollcommand: tkinter._XYScrollCommand = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -309,24 +309,24 @@ class Combobox(Entry): cnf: dict[str, Any] | None = None, *, background: str = ..., - cursor: tk._Cursor = ..., + cursor: tkinter._Cursor = ..., exportselection: bool = ..., font: _FontDescription = ..., foreground: str = ..., height: int = ..., - invalidcommand: tk._EntryValidateCommand = ..., + invalidcommand: tkinter._EntryValidateCommand = ..., justify: Literal["left", "center", "right"] = ..., postcommand: Callable[[], object] | str = ..., show=..., state: str = ..., style: str = ..., - takefocus: tk._TakeFocusValue = ..., - textvariable: tk.Variable = ..., + takefocus: tkinter._TakeFocusValue = ..., + textvariable: tkinter.Variable = ..., validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., - validatecommand: tk._EntryValidateCommand = ..., + validatecommand: tkinter._EntryValidateCommand = ..., values: list[str] | tuple[str, ...] = ..., width: int = ..., - xscrollcommand: tk._XYScrollCommand = ..., + xscrollcommand: tkinter._XYScrollCommand = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def config(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -338,34 +338,34 @@ class Frame(Widget): # (all of these keyword-only arguments are also present there) def __init__( self, - master: tk.Misc | None = None, + master: tkinter.Misc | None = None, *, - border: tk._ScreenUnits = ..., - borderwidth: tk._ScreenUnits = ..., + border: tkinter._ScreenUnits = ..., + borderwidth: tkinter._ScreenUnits = ..., class_: str = "", - cursor: tk._Cursor = "", - height: tk._ScreenUnits = 0, + cursor: tkinter._Cursor = "", + height: tkinter._ScreenUnits = 0, name: str = ..., padding: _Padding = ..., - relief: tk._Relief = ..., + relief: tkinter._Relief = ..., style: str = "", - takefocus: tk._TakeFocusValue = "", - width: tk._ScreenUnits = 0, + takefocus: tkinter._TakeFocusValue = "", + width: tkinter._ScreenUnits = 0, ) -> None: ... @overload def configure( self, cnf: dict[str, Any] | None = None, *, - border: tk._ScreenUnits = ..., - borderwidth: tk._ScreenUnits = ..., - cursor: tk._Cursor = ..., - height: tk._ScreenUnits = ..., + border: tkinter._ScreenUnits = ..., + borderwidth: tkinter._ScreenUnits = ..., + cursor: tkinter._Cursor = ..., + height: tkinter._ScreenUnits = ..., padding: _Padding = ..., - relief: tk._Relief = ..., + relief: tkinter._Relief = ..., style: str = ..., - takefocus: tk._TakeFocusValue = ..., - width: tk._ScreenUnits = ..., + takefocus: tkinter._TakeFocusValue = ..., + width: tkinter._ScreenUnits = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -374,56 +374,56 @@ class Frame(Widget): class Label(Widget): def __init__( self, - master: tk.Misc | None = None, + master: tkinter.Misc | None = None, *, - anchor: tk._Anchor = ..., + anchor: tkinter._Anchor = ..., background: str = "", - border: tk._ScreenUnits = ..., # alias for borderwidth - borderwidth: tk._ScreenUnits = ..., # undocumented + border: tkinter._ScreenUnits = ..., # alias for borderwidth + borderwidth: tkinter._ScreenUnits = ..., # undocumented class_: str = "", compound: _TtkCompound = "", - cursor: tk._Cursor = "", + cursor: tkinter._Cursor = "", font: _FontDescription = ..., foreground: str = "", - image: tk._ImageSpec = "", + image: tkinter._ImageSpec = "", justify: Literal["left", "center", "right"] = ..., name: str = ..., padding: _Padding = ..., - relief: tk._Relief = ..., + relief: tkinter._Relief = ..., state: str = "normal", style: str = "", - takefocus: tk._TakeFocusValue = "", + takefocus: tkinter._TakeFocusValue = "", text: float | str = "", - textvariable: tk.Variable = ..., + textvariable: tkinter.Variable = ..., underline: int = -1, width: int | Literal[""] = "", - wraplength: tk._ScreenUnits = ..., + wraplength: tkinter._ScreenUnits = ..., ) -> None: ... @overload def configure( self, cnf: dict[str, Any] | None = None, *, - anchor: tk._Anchor = ..., + anchor: tkinter._Anchor = ..., background: str = ..., - border: tk._ScreenUnits = ..., - borderwidth: tk._ScreenUnits = ..., + border: tkinter._ScreenUnits = ..., + borderwidth: tkinter._ScreenUnits = ..., compound: _TtkCompound = ..., - cursor: tk._Cursor = ..., + cursor: tkinter._Cursor = ..., font: _FontDescription = ..., foreground: str = ..., - image: tk._ImageSpec = ..., + image: tkinter._ImageSpec = ..., justify: Literal["left", "center", "right"] = ..., padding: _Padding = ..., - relief: tk._Relief = ..., + relief: tkinter._Relief = ..., state: str = ..., style: str = ..., - takefocus: tk._TakeFocusValue = ..., + takefocus: tkinter._TakeFocusValue = ..., text: float | str = ..., - textvariable: tk.Variable = ..., + textvariable: tkinter.Variable = ..., underline: int = ..., width: int | Literal[""] = ..., - wraplength: tk._ScreenUnits = ..., + wraplength: tkinter._ScreenUnits = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -432,42 +432,42 @@ class Label(Widget): class Labelframe(Widget): def __init__( self, - master: tk.Misc | None = None, + master: tkinter.Misc | None = None, *, - border: tk._ScreenUnits = ..., - borderwidth: tk._ScreenUnits = ..., # undocumented + border: tkinter._ScreenUnits = ..., + borderwidth: tkinter._ScreenUnits = ..., # undocumented class_: str = "", - cursor: tk._Cursor = "", - height: tk._ScreenUnits = 0, + cursor: tkinter._Cursor = "", + height: tkinter._ScreenUnits = 0, labelanchor: Literal["nw", "n", "ne", "en", "e", "es", "se", "s", "sw", "ws", "w", "wn"] = ..., - labelwidget: tk.Misc = ..., + labelwidget: tkinter.Misc = ..., name: str = ..., padding: _Padding = ..., - relief: tk._Relief = ..., # undocumented + relief: tkinter._Relief = ..., # undocumented style: str = "", - takefocus: tk._TakeFocusValue = "", + takefocus: tkinter._TakeFocusValue = "", text: float | str = "", underline: int = -1, - width: tk._ScreenUnits = 0, + width: tkinter._ScreenUnits = 0, ) -> None: ... @overload def configure( self, cnf: dict[str, Any] | None = None, *, - border: tk._ScreenUnits = ..., - borderwidth: tk._ScreenUnits = ..., - cursor: tk._Cursor = ..., - height: tk._ScreenUnits = ..., + border: tkinter._ScreenUnits = ..., + borderwidth: tkinter._ScreenUnits = ..., + cursor: tkinter._Cursor = ..., + height: tkinter._ScreenUnits = ..., labelanchor: Literal["nw", "n", "ne", "en", "e", "es", "se", "s", "sw", "ws", "w", "wn"] = ..., - labelwidget: tk.Misc = ..., + labelwidget: tkinter.Misc = ..., padding: _Padding = ..., - relief: tk._Relief = ..., + relief: tkinter._Relief = ..., style: str = ..., - takefocus: tk._TakeFocusValue = ..., + takefocus: tkinter._TakeFocusValue = ..., text: float | str = ..., underline: int = ..., - width: tk._ScreenUnits = ..., + width: tkinter._ScreenUnits = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -478,21 +478,21 @@ LabelFrame = Labelframe class Menubutton(Widget): def __init__( self, - master: tk.Misc | None = None, + master: tkinter.Misc | None = None, *, class_: str = "", compound: _TtkCompound = "", - cursor: tk._Cursor = "", + cursor: tkinter._Cursor = "", direction: Literal["above", "below", "left", "right", "flush"] = "below", - image: tk._ImageSpec = "", - menu: tk.Menu = ..., + image: tkinter._ImageSpec = "", + menu: tkinter.Menu = ..., name: str = ..., padding=..., # undocumented state: str = "normal", style: str = "", - takefocus: tk._TakeFocusValue = ..., + takefocus: tkinter._TakeFocusValue = ..., text: float | str = "", - textvariable: tk.Variable = ..., + textvariable: tkinter.Variable = ..., underline: int = -1, width: int | Literal[""] = "", ) -> None: ... @@ -502,16 +502,16 @@ class Menubutton(Widget): cnf: dict[str, Any] | None = None, *, compound: _TtkCompound = ..., - cursor: tk._Cursor = ..., + cursor: tkinter._Cursor = ..., direction: Literal["above", "below", "left", "right", "flush"] = ..., - image: tk._ImageSpec = ..., - menu: tk.Menu = ..., + image: tkinter._ImageSpec = ..., + menu: tkinter.Menu = ..., padding=..., state: str = ..., style: str = ..., - takefocus: tk._TakeFocusValue = ..., + takefocus: tkinter._TakeFocusValue = ..., text: float | str = ..., - textvariable: tk.Variable = ..., + textvariable: tkinter.Variable = ..., underline: int = ..., width: int | Literal[""] = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @@ -522,15 +522,15 @@ class Menubutton(Widget): class Notebook(Widget): def __init__( self, - master: tk.Misc | None = None, + master: tkinter.Misc | None = None, *, class_: str = "", - cursor: tk._Cursor = "", + cursor: tkinter._Cursor = "", height: int = 0, name: str = ..., padding: _Padding = ..., style: str = "", - takefocus: tk._TakeFocusValue = ..., + takefocus: tkinter._TakeFocusValue = ..., width: int = 0, ) -> None: ... @overload @@ -538,11 +538,11 @@ class Notebook(Widget): self, cnf: dict[str, Any] | None = None, *, - cursor: tk._Cursor = ..., + cursor: tkinter._Cursor = ..., height: int = ..., padding: _Padding = ..., style: str = ..., - takefocus: tk._TakeFocusValue = ..., + takefocus: tkinter._TakeFocusValue = ..., width: int = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload @@ -550,7 +550,7 @@ class Notebook(Widget): config = configure def add( self, - child: tk.Widget, + child: tkinter.Widget, *, state: Literal["normal", "disabled", "hidden"] = ..., sticky: str = ..., # consists of letters 'n', 's', 'w', 'e', no repeats, may be empty @@ -559,7 +559,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: tk._Compound = ..., + compound: tkinter._Compound = ..., underline: int = ..., ) -> None: ... def forget(self, tab_id) -> None: ... @@ -572,31 +572,31 @@ class Notebook(Widget): def tabs(self): ... def enable_traversal(self) -> None: ... -class Panedwindow(Widget, tk.PanedWindow): +class Panedwindow(Widget, tkinter.PanedWindow): def __init__( self, - master: tk.Misc | None = None, + master: tkinter.Misc | None = None, *, class_: str = "", - cursor: tk._Cursor = "", + cursor: tkinter._Cursor = "", # width and height for tkinter.ttk.Panedwindow are int but for tkinter.PanedWindow they are screen units height: int = 0, name: str = ..., orient: Literal["vertical", "horizontal"] = "vertical", # can't be changed with configure() style: str = "", - takefocus: tk._TakeFocusValue = "", + takefocus: tkinter._TakeFocusValue = "", width: int = 0, ) -> None: ... - def add(self, child: tk.Widget, *, weight: int = ..., **kw) -> None: ... + def add(self, child: tkinter.Widget, *, weight: int = ..., **kw) -> None: ... @overload # type: ignore[override] def configure( self, cnf: dict[str, Any] | None = None, *, - cursor: tk._Cursor = ..., + cursor: tkinter._Cursor = ..., height: int = ..., style: str = ..., - takefocus: tk._TakeFocusValue = ..., + takefocus: tkinter._TakeFocusValue = ..., width: int = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload @@ -607,10 +607,10 @@ class Panedwindow(Widget, tk.PanedWindow): self, cnf: dict[str, Any] | None = None, *, - cursor: tk._Cursor = ..., + cursor: tkinter._Cursor = ..., height: int = ..., style: str = ..., - takefocus: tk._TakeFocusValue = ..., + takefocus: tkinter._TakeFocusValue = ..., width: int = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload @@ -625,36 +625,36 @@ PanedWindow = Panedwindow class Progressbar(Widget): def __init__( self, - master: tk.Misc | None = None, + master: tkinter.Misc | None = None, *, class_: str = "", - cursor: tk._Cursor = "", - length: tk._ScreenUnits = 100, + cursor: tkinter._Cursor = "", + length: tkinter._ScreenUnits = 100, maximum: float = 100, mode: Literal["determinate", "indeterminate"] = "determinate", name: str = ..., orient: Literal["horizontal", "vertical"] = "horizontal", phase: int = 0, # docs say read-only but assigning int to this works style: str = "", - takefocus: tk._TakeFocusValue = "", + takefocus: tkinter._TakeFocusValue = "", value: float = 0.0, - variable: tk.IntVar | tk.DoubleVar = ..., + variable: tkinter.IntVar | tkinter.DoubleVar = ..., ) -> None: ... @overload def configure( self, cnf: dict[str, Any] | None = None, *, - cursor: tk._Cursor = ..., - length: tk._ScreenUnits = ..., + cursor: tkinter._Cursor = ..., + length: tkinter._ScreenUnits = ..., maximum: float = ..., mode: Literal["determinate", "indeterminate"] = ..., orient: Literal["horizontal", "vertical"] = ..., phase: int = ..., style: str = ..., - takefocus: tk._TakeFocusValue = ..., + takefocus: tkinter._TakeFocusValue = ..., value: float = ..., - variable: tk.IntVar | tk.DoubleVar = ..., + 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]: ... @@ -666,23 +666,23 @@ class Progressbar(Widget): class Radiobutton(Widget): def __init__( self, - master: tk.Misc | None = None, + master: tkinter.Misc | None = None, *, class_: str = "", - command: tk._ButtonCommand = "", + command: tkinter._ButtonCommand = "", compound: _TtkCompound = "", - cursor: tk._Cursor = "", - image: tk._ImageSpec = "", + cursor: tkinter._Cursor = "", + image: tkinter._ImageSpec = "", name: str = ..., padding=..., # undocumented state: str = "normal", style: str = "", - takefocus: tk._TakeFocusValue = ..., + takefocus: tkinter._TakeFocusValue = ..., text: float | str = "", - textvariable: tk.Variable = ..., + textvariable: tkinter.Variable = ..., underline: int = -1, value: Any = "1", - variable: tk.Variable | Literal[""] = ..., + variable: tkinter.Variable | Literal[""] = ..., width: int | Literal[""] = "", ) -> None: ... @overload @@ -690,19 +690,19 @@ class Radiobutton(Widget): self, cnf: dict[str, Any] | None = None, *, - command: tk._ButtonCommand = ..., + command: tkinter._ButtonCommand = ..., compound: _TtkCompound = ..., - cursor: tk._Cursor = ..., - image: tk._ImageSpec = ..., + cursor: tkinter._Cursor = ..., + image: tkinter._ImageSpec = ..., padding=..., state: str = ..., style: str = ..., - takefocus: tk._TakeFocusValue = ..., + takefocus: tkinter._TakeFocusValue = ..., text: float | str = ..., - textvariable: tk.Variable = ..., + textvariable: tkinter.Variable = ..., underline: int = ..., value: Any = ..., - variable: tk.Variable | Literal[""] = ..., + variable: tkinter.Variable | Literal[""] = ..., width: int | Literal[""] = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload @@ -711,24 +711,24 @@ class Radiobutton(Widget): def invoke(self) -> Any: ... # type ignore, because identify() methods of Widget and tkinter.Scale are incompatible -class Scale(Widget, tk.Scale): # type: ignore[misc] +class Scale(Widget, tkinter.Scale): # type: ignore[misc] def __init__( self, - master: tk.Misc | None = None, + master: tkinter.Misc | None = None, *, class_: str = "", command: str | Callable[[str], object] = "", - cursor: tk._Cursor = "", + cursor: tkinter._Cursor = "", from_: float = 0, - length: tk._ScreenUnits = 100, + length: tkinter._ScreenUnits = 100, name: str = ..., orient: Literal["horizontal", "vertical"] = "horizontal", state: str = ..., # undocumented style: str = "", - takefocus: tk._TakeFocusValue = ..., + takefocus: tkinter._TakeFocusValue = ..., to: float = 1.0, value: float = 0, - variable: tk.IntVar | tk.DoubleVar = ..., + variable: tkinter.IntVar | tkinter.DoubleVar = ..., ) -> None: ... @overload # type: ignore[override] def configure( @@ -736,16 +736,16 @@ class Scale(Widget, tk.Scale): # type: ignore[misc] cnf: dict[str, Any] | None = None, *, command: str | Callable[[str], object] = ..., - cursor: tk._Cursor = ..., + cursor: tkinter._Cursor = ..., from_: float = ..., - length: tk._ScreenUnits = ..., + length: tkinter._ScreenUnits = ..., orient: Literal["horizontal", "vertical"] = ..., state: str = ..., style: str = ..., - takefocus: tk._TakeFocusValue = ..., + takefocus: tkinter._TakeFocusValue = ..., to: float = ..., value: float = ..., - variable: tk.IntVar | tk.DoubleVar = ..., + 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]: ... @@ -756,34 +756,34 @@ class Scale(Widget, tk.Scale): # type: ignore[misc] cnf: dict[str, Any] | None = None, *, command: str | Callable[[str], object] = ..., - cursor: tk._Cursor = ..., + cursor: tkinter._Cursor = ..., from_: float = ..., - length: tk._ScreenUnits = ..., + length: tkinter._ScreenUnits = ..., orient: Literal["horizontal", "vertical"] = ..., state: str = ..., style: str = ..., - takefocus: tk._TakeFocusValue = ..., + takefocus: tkinter._TakeFocusValue = ..., to: float = ..., value: float = ..., - variable: tk.IntVar | tk.DoubleVar = ..., + 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: int | None = None, y: int | None = None) -> float: ... # type ignore, because identify() methods of Widget and tkinter.Scale are incompatible -class Scrollbar(Widget, tk.Scrollbar): # type: ignore[misc] +class Scrollbar(Widget, tkinter.Scrollbar): # type: ignore[misc] def __init__( self, - master: tk.Misc | None = None, + master: tkinter.Misc | None = None, *, class_: str = "", command: Callable[..., tuple[float, float] | None] | str = "", - cursor: tk._Cursor = "", + cursor: tkinter._Cursor = "", name: str = ..., orient: Literal["horizontal", "vertical"] = "vertical", style: str = "", - takefocus: tk._TakeFocusValue = "", + takefocus: tkinter._TakeFocusValue = "", ) -> None: ... @overload # type: ignore[override] def configure( @@ -791,10 +791,10 @@ class Scrollbar(Widget, tk.Scrollbar): # type: ignore[misc] cnf: dict[str, Any] | None = None, *, command: Callable[..., tuple[float, float] | None] | str = ..., - cursor: tk._Cursor = ..., + cursor: tkinter._Cursor = ..., orient: Literal["horizontal", "vertical"] = ..., style: str = ..., - takefocus: tk._TakeFocusValue = ..., + takefocus: tkinter._TakeFocusValue = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -805,10 +805,10 @@ class Scrollbar(Widget, tk.Scrollbar): # type: ignore[misc] cnf: dict[str, Any] | None = None, *, command: Callable[..., tuple[float, float] | None] | str = ..., - cursor: tk._Cursor = ..., + cursor: tkinter._Cursor = ..., orient: Literal["horizontal", "vertical"] = ..., style: str = ..., - takefocus: tk._TakeFocusValue = ..., + takefocus: tkinter._TakeFocusValue = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def config(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -816,24 +816,24 @@ class Scrollbar(Widget, tk.Scrollbar): # type: ignore[misc] class Separator(Widget): def __init__( self, - master: tk.Misc | None = None, + master: tkinter.Misc | None = None, *, class_: str = "", - cursor: tk._Cursor = "", + cursor: tkinter._Cursor = "", name: str = ..., orient: Literal["horizontal", "vertical"] = "horizontal", style: str = "", - takefocus: tk._TakeFocusValue = "", + takefocus: tkinter._TakeFocusValue = "", ) -> None: ... @overload def configure( self, cnf: dict[str, Any] | None = None, *, - cursor: tk._Cursor = ..., + cursor: tkinter._Cursor = ..., orient: Literal["horizontal", "vertical"] = ..., style: str = ..., - takefocus: tk._TakeFocusValue = ..., + takefocus: tkinter._TakeFocusValue = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -842,22 +842,22 @@ class Separator(Widget): class Sizegrip(Widget): def __init__( self, - master: tk.Misc | None = None, + master: tkinter.Misc | None = None, *, class_: str = "", - cursor: tk._Cursor = ..., + cursor: tkinter._Cursor = ..., name: str = ..., style: str = "", - takefocus: tk._TakeFocusValue = "", + takefocus: tkinter._TakeFocusValue = "", ) -> None: ... @overload def configure( self, cnf: dict[str, Any] | None = None, *, - cursor: tk._Cursor = ..., + cursor: tkinter._Cursor = ..., style: str = ..., - takefocus: tk._TakeFocusValue = ..., + takefocus: tkinter._TakeFocusValue = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -866,33 +866,33 @@ class Sizegrip(Widget): class Spinbox(Entry): def __init__( self, - master: tk.Misc | None = None, + master: tkinter.Misc | None = None, *, background: str = ..., # undocumented class_: str = "", command: Callable[[], object] | str | list[str] | tuple[str, ...] = "", - cursor: tk._Cursor = "", + cursor: tkinter._Cursor = "", exportselection: bool = ..., # undocumented font: _FontDescription = ..., # undocumented foreground: str = ..., # undocumented format: str = "", from_: float = 0, increment: float = 1, - invalidcommand: tk._EntryValidateCommand = ..., # undocumented + invalidcommand: tkinter._EntryValidateCommand = ..., # undocumented justify: Literal["left", "center", "right"] = ..., # undocumented name: str = ..., show=..., # undocumented state: str = "normal", style: str = "", - takefocus: tk._TakeFocusValue = ..., - textvariable: tk.Variable = ..., # undocumented + takefocus: tkinter._TakeFocusValue = ..., + textvariable: tkinter.Variable = ..., # undocumented to: float = 0, validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = "none", - validatecommand: tk._EntryValidateCommand = "", + validatecommand: tkinter._EntryValidateCommand = "", values: list[str] | tuple[str, ...] = ..., width: int = ..., # undocumented wrap: bool = False, - xscrollcommand: tk._XYScrollCommand = "", + xscrollcommand: tkinter._XYScrollCommand = "", ) -> None: ... @overload # type: ignore[override] def configure( @@ -901,27 +901,27 @@ class Spinbox(Entry): *, background: str = ..., command: Callable[[], object] | str | list[str] | tuple[str, ...] = ..., - cursor: tk._Cursor = ..., + cursor: tkinter._Cursor = ..., exportselection: bool = ..., font: _FontDescription = ..., foreground: str = ..., format: str = ..., from_: float = ..., increment: float = ..., - invalidcommand: tk._EntryValidateCommand = ..., + invalidcommand: tkinter._EntryValidateCommand = ..., justify: Literal["left", "center", "right"] = ..., show=..., state: str = ..., style: str = ..., - takefocus: tk._TakeFocusValue = ..., - textvariable: tk.Variable = ..., + takefocus: tkinter._TakeFocusValue = ..., + textvariable: tkinter.Variable = ..., to: float = ..., validate: Literal["none", "focus", "focusin", "focusout", "key", "all"] = ..., - validatecommand: tk._EntryValidateCommand = ..., + validatecommand: tkinter._EntryValidateCommand = ..., values: list[str] | tuple[str, ...] = ..., width: int = ..., wrap: bool = ..., - xscrollcommand: tk._XYScrollCommand = ..., + xscrollcommand: tkinter._XYScrollCommand = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -945,7 +945,7 @@ class _TreeviewTagDict(TypedDict): class _TreeviewHeaderDict(TypedDict): text: str image: list[str] | Literal[""] - anchor: tk._Anchor + anchor: tkinter._Anchor command: str state: str # Doesn't seem to appear anywhere else than in these dicts @@ -953,17 +953,17 @@ class _TreeviewColumnDict(TypedDict): width: int minwidth: int stretch: bool # actually 0 or 1 - anchor: tk._Anchor + anchor: tkinter._Anchor id: str -class Treeview(Widget, tk.XView, tk.YView): +class Treeview(Widget, tkinter.XView, tkinter.YView): def __init__( self, - master: tk.Misc | None = None, + master: tkinter.Misc | None = None, *, class_: str = "", columns: str | list[str] | list[int] | list[str | int] | tuple[str | int, ...] = "", - cursor: tk._Cursor = "", + cursor: tkinter._Cursor = "", displaycolumns: str | int | list[str] | tuple[str, ...] | list[int] | tuple[int, ...] = ("#all",), height: int = 10, name: str = ..., @@ -975,9 +975,9 @@ class Treeview(Widget, tk.XView, tk.YView): # surprised if someone is using it. show: Literal["tree", "headings", "tree headings", ""] | list[str] | tuple[str, ...] = ("tree", "headings"), style: str = "", - takefocus: tk._TakeFocusValue = ..., - xscrollcommand: tk._XYScrollCommand = "", - yscrollcommand: tk._XYScrollCommand = "", + takefocus: tkinter._TakeFocusValue = ..., + xscrollcommand: tkinter._XYScrollCommand = "", + yscrollcommand: tkinter._XYScrollCommand = "", ) -> None: ... @overload def configure( @@ -985,16 +985,16 @@ class Treeview(Widget, tk.XView, tk.YView): cnf: dict[str, Any] | None = None, *, columns: str | list[str] | list[int] | list[str | int] | tuple[str | int, ...] = ..., - cursor: tk._Cursor = ..., + cursor: tkinter._Cursor = ..., displaycolumns: str | int | list[str] | tuple[str, ...] | list[int] | tuple[int, ...] = ..., height: int = ..., padding: _Padding = ..., selectmode: Literal["extended", "browse", "none"] = ..., show: Literal["tree", "headings", "tree headings", ""] | list[str] | tuple[str, ...] = ..., style: str = ..., - takefocus: tk._TakeFocusValue = ..., - xscrollcommand: tk._XYScrollCommand = ..., - yscrollcommand: tk._XYScrollCommand = ..., + takefocus: tkinter._TakeFocusValue = ..., + xscrollcommand: tkinter._XYScrollCommand = ..., + yscrollcommand: tkinter._XYScrollCommand = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... @@ -1021,7 +1021,7 @@ class Treeview(Widget, tk.XView, tk.YView): width: int = ..., minwidth: int = ..., stretch: bool = ..., - anchor: tk._Anchor = ..., + anchor: tkinter._Anchor = ..., # id is read-only ) -> _TreeviewColumnDict | None: ... def delete(self, *items: str | int) -> None: ... @@ -1050,8 +1050,8 @@ class Treeview(Widget, tk.XView, tk.YView): option: None = None, *, text: str = ..., - image: tk._ImageSpec = ..., - anchor: tk._Anchor = ..., + image: tkinter._ImageSpec = ..., + anchor: tkinter._Anchor = ..., command: str | Callable[[], object] = ..., ) -> None: ... # Internal Method. Leave untyped: @@ -1069,7 +1069,7 @@ class Treeview(Widget, tk.XView, tk.YView): *, id: str | int = ..., # same as iid text: str = ..., - image: tk._ImageSpec = ..., + image: tkinter._ImageSpec = ..., values: list[Any] | tuple[Any, ...] = ..., open: bool = ..., tags: str | list[str] | tuple[str, ...] = ..., @@ -1095,7 +1095,7 @@ class Treeview(Widget, tk.XView, tk.YView): option: None = None, *, text: str = ..., - image: tk._ImageSpec = ..., + image: tkinter._ImageSpec = ..., values: list[Any] | tuple[Any, ...] | Literal[""] = ..., open: bool = ..., tags: str | list[str] | tuple[str, ...] = ..., @@ -1133,7 +1133,7 @@ class Treeview(Widget, tk.XView, tk.YView): # Also, it's 'callback' instead of 'func' here. @overload def tag_bind( - self, tagname: str, sequence: str | None = None, callback: Callable[[tk.Event[Treeview]], object] | None = None + self, tagname: str, sequence: str | None = None, callback: Callable[[tkinter.Event[Treeview]], object] | None = None ) -> str: ... @overload def tag_bind(self, tagname: str, sequence: str | None, callback: str) -> None: ... @@ -1155,7 +1155,7 @@ class Treeview(Widget, tk.XView, tk.YView): foreground: str = ..., background: str = ..., font: _FontDescription = ..., - image: tk._ImageSpec = ..., + image: tkinter._ImageSpec = ..., ) -> _TreeviewTagDict | MaybeNone: ... # can be None but annoying to check @overload def tag_has(self, tagname: str, item: None = None) -> tuple[str, ...]: ... @@ -1169,23 +1169,23 @@ class LabeledScale(Frame): # (all the keyword-only args except compound are from there) def __init__( self, - master: tk.Misc | None = None, - variable: tk.IntVar | tk.DoubleVar | None = None, + master: tkinter.Misc | None = None, + variable: tkinter.IntVar | tkinter.DoubleVar | None = None, from_: float = 0, to: float = 10, *, - border: tk._ScreenUnits = ..., - borderwidth: tk._ScreenUnits = ..., + border: tkinter._ScreenUnits = ..., + borderwidth: tkinter._ScreenUnits = ..., class_: str = "", compound: Literal["top", "bottom"] = "top", - cursor: tk._Cursor = "", - height: tk._ScreenUnits = 0, + cursor: tkinter._Cursor = "", + height: tkinter._ScreenUnits = 0, name: str = ..., padding: _Padding = ..., - relief: tk._Relief = ..., + relief: tkinter._Relief = ..., style: str = "", - takefocus: tk._TakeFocusValue = "", - width: tk._ScreenUnits = 0, + takefocus: tkinter._TakeFocusValue = "", + width: tkinter._ScreenUnits = 0, ) -> None: ... # destroy is overridden, signature does not change value: Any @@ -1193,14 +1193,14 @@ class LabeledScale(Frame): class OptionMenu(Menubutton): def __init__( self, - master: tk.Misc | None, - variable: tk.StringVar, + master: tkinter.Misc | None, + variable: tkinter.StringVar, default: str | None = None, *values: str, # rest of these are keyword-only because *args syntax used above style: str = "", direction: Literal["above", "below", "left", "right", "flush"] = "below", - command: Callable[[tk.StringVar], object] | None = None, + command: Callable[[tkinter.StringVar], object] | None = None, ) -> None: ... # configure, config, cget, destroy are inherited from Menubutton # destroy and __setitem__ are overridden, signature does not change diff --git a/stubs/ttkthemes/ttkthemes/themed_style.pyi b/stubs/ttkthemes/ttkthemes/themed_style.pyi index 0e46a4430101..e880f0718dc2 100644 --- a/stubs/ttkthemes/ttkthemes/themed_style.pyi +++ b/stubs/ttkthemes/ttkthemes/themed_style.pyi @@ -1,11 +1,11 @@ -import tkinter as tk +import tkinter from tkinter import ttk from ._widget import ThemedWidget class ThemedStyle(ttk.Style, ThemedWidget): def __init__( - self, master: tk.Misc | None = ..., *, theme: str | None = ..., gif_override: bool | None = ..., **kwargs + self, master: tkinter.Misc | None = ..., *, theme: str | None = ..., gif_override: bool | None = ..., **kwargs ) -> None: ... # theme_use() can't return None (differs from ttk.Style) def theme_use(self, theme_name: str | None = None) -> str: ... # type: ignore[override] diff --git a/stubs/ttkthemes/ttkthemes/themed_tk.pyi b/stubs/ttkthemes/ttkthemes/themed_tk.pyi index b05d89e21c06..8bf6ac4c6e5f 100644 --- a/stubs/ttkthemes/ttkthemes/themed_tk.pyi +++ b/stubs/ttkthemes/ttkthemes/themed_tk.pyi @@ -1,9 +1,9 @@ -import tkinter as tk +import tkinter from _typeshed import Incomplete from ._widget import ThemedWidget -class ThemedTk(tk.Tk, ThemedWidget): +class ThemedTk(tkinter.Tk, ThemedWidget): def __init__( self, # non-keyword-only args copied from tkinter.Tk From 1bd161edd2247ccfc1fb3fb36b4c0d3ffb68c872 Mon Sep 17 00:00:00 2001 From: Avasam Date: Thu, 27 Mar 2025 19:18:11 -0400 Subject: [PATCH 3/4] Better comment --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e11f10c091b1..e45a67f9f4d9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -214,7 +214,7 @@ convention = "pep257" # https://docs.astral.sh/ruff/settings/#lint_pydocstyle_co "pandas"="pd" "seaborn"="sns" "tensorflow"="tf" -# "tkinter"="tk" # Causes issues with stubtest +# "tkinter"="tk" # Causes name conflict in stdlib/tkinter/ttk.py with Style.tk "holoviews"="hv" "panel"="pn" "plotly.express"="px" From f2ee9fb3788ceb6b1976d36ce7bd6b21a918f365 Mon Sep 17 00:00:00 2001 From: Avasam Date: Mon, 31 Mar 2025 13:00:17 -0400 Subject: [PATCH 4/4] Simplify tkinter config in lint.flake8-import-conventions --- pyproject.toml | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6084c6588b52..8c6138b47128 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -208,22 +208,9 @@ ignore = [ [tool.ruff.lint.pydocstyle] convention = "pep257" # https://docs.astral.sh/ruff/settings/#lint_pydocstyle_convention -[tool.ruff.lint.flake8-import-conventions.aliases] -# Same as default -"altair"="alt" -"matplotlib"="mpl" -"matplotlib.pyplot"="plt" -"numpy"="np" -"pandas"="pd" -"seaborn"="sns" -"tensorflow"="tf" -# "tkinter"="tk" # Causes name conflict in stdlib/tkinter/ttk.py with Style.tk -"holoviews"="hv" -"panel"="pn" -"plotly.express"="px" -"polars"="pl" -"pyarrow"="pa" -"xml.etree.ElementTree"="ET" +[tool.ruff.lint.flake8-import-conventions.extend-aliases] +# Using "tk" causes name conflict in stdlib/tkinter/ttk.py with Style.tk +"tkinter" = "tkinter" # Added "numpy.typing" = "npt"