4 from typing import Any, List, Tuple, Union, overload
5 from typing_extensions import Literal, TypedDict
7 NORMAL: Literal["normal"]
8 ROMAN: Literal["roman"]
10 ITALIC: Literal["italic"]
12 _FontDescription = Union[
15 # A font object constructed in Python
17 # ("Helvetica", 12, BOLD)
20 # A font object constructed in Tcl
24 class _FontDict(TypedDict):
27 weight: Literal["normal", "bold"]
28 slant: Literal["roman", "italic"]
32 class _MetricsDict(TypedDict):
43 # In tkinter, 'root' refers to tkinter.Tk by convention, but the code
44 # actually works with any tkinter widget so we use tkinter.Misc.
45 root: tkinter.Misc | None = ...,
46 font: _FontDescription | None = ...,
47 name: str | None = ...,
52 weight: Literal["normal", "bold"] = ...,
53 slant: Literal["roman", "italic"] = ...,
54 underline: bool = ...,
55 overstrike: bool = ...,
57 def __setitem__(self, key: str, value: Any) -> None: ...
59 def cget(self, option: Literal["family"]) -> str: ...
61 def cget(self, option: Literal["size"]) -> int: ...
63 def cget(self, option: Literal["weight"]) -> Literal["normal", "bold"]: ...
65 def cget(self, option: Literal["slant"]) -> Literal["roman", "italic"]: ...
67 def cget(self, option: Literal["underline", "overstrike"]) -> bool: ...
69 def cget(self, option: str) -> Any: ...
72 def actual(self, option: Literal["family"], displayof: tkinter.Misc | None = ...) -> str: ...
74 def actual(self, option: Literal["size"], displayof: tkinter.Misc | None = ...) -> int: ...
76 def actual(self, option: Literal["weight"], displayof: tkinter.Misc | None = ...) -> Literal["normal", "bold"]: ...
78 def actual(self, option: Literal["slant"], displayof: tkinter.Misc | None = ...) -> Literal["roman", "italic"]: ...
80 def actual(self, option: Literal["underline", "overstrike"], displayof: tkinter.Misc | None = ...) -> bool: ...
82 def actual(self, option: None, displayof: tkinter.Misc | None = ...) -> _FontDict: ...
84 def actual(self, *, displayof: tkinter.Misc | None = ...) -> _FontDict: ...
90 weight: Literal["normal", "bold"] = ...,
91 slant: Literal["roman", "italic"] = ...,
92 underline: bool = ...,
93 overstrike: bool = ...,
94 ) -> _FontDict | None: ...
96 def copy(self) -> Font: ...
98 def metrics(self, __option: Literal["ascent", "descent", "linespace"], *, displayof: tkinter.Misc | None = ...) -> int: ...
100 def metrics(self, __option: Literal["fixed"], *, displayof: tkinter.Misc | None = ...) -> bool: ...
102 def metrics(self, *, displayof: tkinter.Misc | None = ...) -> _MetricsDict: ...
103 def measure(self, text: str, displayof: tkinter.Misc | None = ...) -> int: ...
105 def families(root: tkinter.Misc | None = ..., displayof: tkinter.Misc | None = ...) -> Tuple[str, ...]: ...
106 def names(root: tkinter.Misc | None = ...) -> Tuple[str, ...]: ...
108 if sys.version_info >= (3, 10):
109 def nametofont(name: str, root: tkinter.Misc | None = ...) -> Font: ...
112 def nametofont(name: str) -> Font: ...