Stubs for ttkthemes (#6024)

This commit is contained in:
Akuli
2021-09-10 16:59:12 +03:00
committed by GitHub
parent 392c81d767
commit e69ca588ac
10 changed files with 93 additions and 3 deletions

View File

@@ -59,6 +59,7 @@
"stubs/simplejson",
"stubs/slumber",
"stubs/stripe",
"stubs/ttkthemes",
"stubs/vobject",
"stubs/waitress",
"stubs/Werkzeug"

View File

@@ -578,6 +578,7 @@ class _ExceptionReportingCallback(Protocol):
class Tk(Misc, Wm):
master: None
def __init__(
# please update ttkthemes stub if you change this
self,
screenName: str | None = ...,
baseName: str | None = ...,

View File

@@ -14,7 +14,7 @@ _TtkCompound = Literal["text", "image", tkinter._Compound]
class Style:
master: Any
tk: _tkinter.TkappType
def __init__(self, master: Any | None = ...): ...
def __init__(self, master: tkinter.Misc | 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 = ...): ...
@@ -24,8 +24,11 @@ class Style:
def element_options(self, elementname): ...
def theme_create(self, themename, parent: Any | None = ..., settings: Any | None = ...): ...
def theme_settings(self, themename, settings): ...
def theme_names(self): ...
def theme_use(self, themename: Any | None = ...): ...
def theme_names(self) -> Tuple[str, ...]: ...
@overload
def theme_use(self, themename: str) -> None: ...
@overload
def theme_use(self, themename: None = ...) -> str: ...
class Widget(tkinter.Widget):
def __init__(self, master: tkinter.Misc | None, widgetname, kw: Any | None = ...): ...

View File

@@ -0,0 +1 @@
version = "3.2"

View File

@@ -0,0 +1,7 @@
from collections.abc import Sequence
from ttkthemes.themed_style import ThemedStyle as ThemedStyle
from ttkthemes.themed_tk import ThemedTk as ThemedTk
# actually a list, but shouldn't be modified
THEMES: Sequence[str]

View File

@@ -0,0 +1,2 @@
def shift_hue(image, hue): ...
def make_transparent(image): ...

View File

@@ -0,0 +1,7 @@
from typing import Any
def temporary_chdir(new_dir) -> None: ...
def get_file_directory(): ...
def get_temp_directory(): ...
def get_themes_directory(theme_name: Any | None = ..., png: bool = ...): ...
def create_directory(directory): ...

View File

@@ -0,0 +1,26 @@
import _tkinter
from _typeshed import StrPath
from typing import ClassVar
class ThemedWidget:
pixmap_themes: ClassVar[list[str]]
PACKAGES: ClassVar[dict[str, str]]
tk: _tkinter.TkappType
png_support: bool
def __init__(self, tk_interpreter, gif_override: bool = ...) -> None: ...
def set_theme(self, theme_name: str) -> None: ...
def get_themes(self) -> list[str]: ...
@property
def themes(self) -> list[str]: ...
@property
def current_theme(self) -> str: ...
def set_theme_advanced(
self,
theme_name: str,
brightness: float = ...,
saturation: float = ...,
hue: float = ...,
preserve_transparency: bool = ...,
output_dir: StrPath | None = ...,
advanced_name: str = ...,
) -> None: ...

View File

@@ -0,0 +1,12 @@
import tkinter
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
) -> None: ...
# theme_use() can't return None (differs from ttk.Style)
def theme_use(self, theme_name: str | None = ...) -> str: ... # type: ignore
def theme_names(self) -> list[str]: ... # type: ignore

View File

@@ -0,0 +1,30 @@
import tkinter
from typing import Any
from ._widget import ThemedWidget
class ThemedTk(tkinter.Tk, ThemedWidget):
def __init__(
self,
# non-keyword-only args copied from tkinter.Tk
screenName: str | None = ...,
baseName: str | None = ...,
className: str = ...,
useTk: bool = ...,
sync: bool = ...,
use: str | None = ...,
*,
theme: str | None = ...,
# fonts argument does nothing
toplevel: bool | None = ...,
themebg: bool | None = ...,
background: bool | None = ..., # old alias for themebg
gif_override: bool = ...,
) -> None: ...
def set_theme(self, theme_name, toplevel: bool | None = ..., themebg: bool | None = ...) -> None: ...
# TODO: currently no good way to say "use the same big list of kwargs as parent class but also add these"
def config(self, kw: Any | None = ..., **kwargs): ... # type: ignore
def cget(self, k): ...
def configure(self, kw: Any | None = ..., **kwargs): ... # type: ignore
def __getitem__(self, k): ...
def __setitem__(self, k, v): ...