Allow any number of trailing font options in tkinter font description (#13240)

This commit is contained in:
Brian Schubert
2024-12-18 18:39:57 -05:00
committed by GitHub
parent bd728fbfae
commit 3157273331

View File

@@ -3,7 +3,7 @@ import itertools
import sys
import tkinter
from typing import Any, ClassVar, Final, Literal, TypedDict, overload
from typing_extensions import TypeAlias
from typing_extensions import TypeAlias, Unpack
if sys.version_info >= (3, 9):
__all__ = ["NORMAL", "ROMAN", "BOLD", "ITALIC", "nametofont", "Font", "families", "names"]
@@ -18,9 +18,9 @@ _FontDescription: TypeAlias = (
| Font # A font object constructed in Python
| list[Any] # ["Helvetica", 12, BOLD]
| tuple[str] # ("Liberation Sans",) needs wrapping in tuple/list to handle spaces
| tuple[str, int] # ("Liberation Sans", 12)
| tuple[str, int, str] # ("Liberation Sans", 12, "bold")
| tuple[str, int, list[str] | tuple[str, ...]] # e.g. bold and italic
# ("Liberation Sans", 12) or ("Liberation Sans", 12, "bold", "italic", "underline")
| tuple[str, int, Unpack[tuple[str, ...]]] # Any number of trailing options is permitted
| tuple[str, int, list[str] | tuple[str, ...]] # Options can also be passed as list/tuple
| _tkinter.Tcl_Obj # A font object constructed in Tcl
)