mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 13:04:46 +08:00
Add some missing type hints to tkinter (#6359)
Co-authored-by: Akuli <akuviljanen17@gmail.com>
This commit is contained in:
@@ -5,7 +5,7 @@ from tkinter.font import _FontDescription
|
||||
from typing import Any, Callable, Union, overload
|
||||
from typing_extensions import Literal, TypedDict
|
||||
|
||||
def tclobjs_to_py(adict): ...
|
||||
def tclobjs_to_py(adict: dict[Any, Any]) -> dict[Any, Any]: ...
|
||||
def setup_master(master: Any | None = ...): ...
|
||||
|
||||
# from ttk_widget (aka ttk::widget) manual page, differs from tkinter._Compound
|
||||
@@ -14,16 +14,16 @@ _TtkCompound = Literal["text", "image", tkinter._Compound]
|
||||
class Style:
|
||||
master: Any
|
||||
tk: _tkinter.TkappType
|
||||
def __init__(self, master: tkinter.Misc | None = ...): ...
|
||||
def __init__(self, master: tkinter.Misc | None = ...) -> None: ...
|
||||
def configure(self, style, query_opt: Any | None = ..., **kw): ...
|
||||
def map(self, style, query_opt: Any | None = ..., **kw): ...
|
||||
def lookup(self, style, option, state: Any | None = ..., default: Any | None = ...): ...
|
||||
def layout(self, style, layoutspec: Any | None = ...): ...
|
||||
def element_create(self, elementname, etype, *args, **kw): ...
|
||||
def element_create(self, elementname, etype, *args, **kw) -> None: ...
|
||||
def element_names(self): ...
|
||||
def element_options(self, elementname): ...
|
||||
def theme_create(self, themename, parent: Any | None = ..., settings: Any | None = ...): ...
|
||||
def theme_settings(self, themename, settings): ...
|
||||
def theme_create(self, themename, parent: Any | None = ..., settings: Any | None = ...) -> None: ...
|
||||
def theme_settings(self, themename, settings) -> None: ...
|
||||
def theme_names(self) -> tuple[str, ...]: ...
|
||||
@overload
|
||||
def theme_use(self, themename: str) -> None: ...
|
||||
@@ -31,8 +31,8 @@ class Style:
|
||||
def theme_use(self, themename: None = ...) -> str: ...
|
||||
|
||||
class Widget(tkinter.Widget):
|
||||
def __init__(self, master: tkinter.Misc | None, widgetname, kw: Any | None = ...): ...
|
||||
def identify(self, x, y): ...
|
||||
def __init__(self, master: tkinter.Misc | None, widgetname, kw: Any | None = ...) -> None: ...
|
||||
def identify(self, x: int, y: int) -> str: ...
|
||||
def instate(self, statespec, callback: Any | None = ..., *args, **kw): ...
|
||||
def state(self, statespec: Any | None = ...): ...
|
||||
|
||||
@@ -207,8 +207,8 @@ class Entry(Widget, tkinter.Entry):
|
||||
) -> dict[str, tuple[str, str, str, Any, Any]] | None: ...
|
||||
@overload
|
||||
def config(self, cnf: str) -> tuple[str, str, str, Any, Any]: ...
|
||||
def bbox(self, index): ...
|
||||
def identify(self, x, y): ...
|
||||
def bbox(self, index) -> tuple[int, int, int, int]: ... # type: ignore[override]
|
||||
def identify(self, x: int, y: int) -> str: ...
|
||||
def validate(self): ...
|
||||
|
||||
class Combobox(Entry):
|
||||
@@ -293,8 +293,8 @@ class Combobox(Entry):
|
||||
) -> dict[str, tuple[str, str, str, Any, Any]] | None: ...
|
||||
@overload
|
||||
def config(self, cnf: str) -> tuple[str, str, str, Any, Any]: ...
|
||||
def current(self, newindex: Any | None = ...): ...
|
||||
def set(self, value): ...
|
||||
def current(self, newindex: int | None = ...) -> int: ...
|
||||
def set(self, value: Any) -> None: ...
|
||||
|
||||
class Frame(Widget):
|
||||
def __init__(
|
||||
@@ -521,11 +521,11 @@ class Notebook(Widget):
|
||||
compound: tkinter._Compound = ...,
|
||||
underline: int = ...,
|
||||
) -> None: ...
|
||||
def forget(self, tab_id): ...
|
||||
def hide(self, tab_id): ...
|
||||
def identify(self, x, y): ...
|
||||
def forget(self, tab_id) -> None: ...
|
||||
def hide(self, tab_id) -> None: ...
|
||||
def identify(self, x: int, y: int) -> str: ...
|
||||
def index(self, tab_id): ...
|
||||
def insert(self, pos, child, **kw): ...
|
||||
def insert(self, pos, child, **kw) -> None: ...
|
||||
def select(self, tab_id: Any | None = ...): ...
|
||||
def tab(self, tab_id, option: Any | None = ..., **kw): ...
|
||||
def tabs(self): ...
|
||||
@@ -575,7 +575,7 @@ class Panedwindow(Widget, tkinter.PanedWindow):
|
||||
@overload
|
||||
def config(self, cnf: str) -> tuple[str, str, str, Any, Any]: ...
|
||||
forget: Any
|
||||
def insert(self, pos, child, **kw): ...
|
||||
def insert(self, pos, child, **kw) -> None: ...
|
||||
def pane(self, pane, option: Any | None = ..., **kw): ...
|
||||
def sashpos(self, index, newpos: Any | None = ...): ...
|
||||
|
||||
@@ -618,9 +618,9 @@ class Progressbar(Widget):
|
||||
@overload
|
||||
def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ...
|
||||
config = configure
|
||||
def start(self, interval: Any | None = ...): ...
|
||||
def step(self, amount: Any | None = ...): ...
|
||||
def stop(self): ...
|
||||
def start(self, interval: Literal["idle"] | int | None = ...) -> None: ...
|
||||
def step(self, amount: float | None = ...) -> None: ...
|
||||
def stop(self) -> None: ...
|
||||
|
||||
class Radiobutton(Widget):
|
||||
def __init__(
|
||||
@@ -669,7 +669,8 @@ class Radiobutton(Widget):
|
||||
config = configure
|
||||
def invoke(self) -> Any: ...
|
||||
|
||||
class Scale(Widget, tkinter.Scale):
|
||||
# type ignore, because identify() methods of Widget and tkinter.Scale are incompatible
|
||||
class Scale(Widget, tkinter.Scale): # type: ignore[misc]
|
||||
def __init__(
|
||||
self,
|
||||
master: tkinter.Misc | None = ...,
|
||||
@@ -727,9 +728,10 @@ class Scale(Widget, tkinter.Scale):
|
||||
) -> 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: Any | None = ..., y: Any | None = ...): ...
|
||||
def get(self, x: int | None = ..., y: int | None = ...) -> float: ...
|
||||
|
||||
class Scrollbar(Widget, tkinter.Scrollbar):
|
||||
# type ignore, because identify() methods of Widget and tkinter.Scale are incompatible
|
||||
class Scrollbar(Widget, tkinter.Scrollbar): # type: ignore[misc]
|
||||
def __init__(
|
||||
self,
|
||||
master: tkinter.Misc | None = ...,
|
||||
@@ -1014,7 +1016,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView):
|
||||
anchor: tkinter._Anchor = ...,
|
||||
command: str | Callable[[], Any] = ...,
|
||||
) -> None: ...
|
||||
def identify(self, component, x, y): ...
|
||||
def identify(self, component, x, y): ... # Internal Method. Leave untyped
|
||||
def identify_row(self, y: int) -> str: ...
|
||||
def identify_column(self, x: int) -> str: ...
|
||||
def identify_region(self, x: int, y: int) -> Literal["heading", "separator", "tree", "cell", "nothing"]: ...
|
||||
@@ -1144,4 +1146,4 @@ class OptionMenu(Menubutton):
|
||||
) -> None: ...
|
||||
# configure, config, cget, destroy are inherited from Menubutton
|
||||
# destroy and __setitem__ are overridden, signature does not change
|
||||
def set_menu(self, default: Any | None = ..., *values): ...
|
||||
def set_menu(self, default: Any | None = ..., *values) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user