From 53e22afda9b6c3396225aab942869c2d4ac22dce Mon Sep 17 00:00:00 2001 From: Soujas K Date: Mon, 26 Oct 2026 18:18:58 +0000 Subject: [PATCH 1/2] Add Tk 9.0 text options to ttk.Progressbar Tk 9.0 lets ttk::progressbar show a text label and adds the anchor, font, foreground, justify, text and wraplength options. Progressbar has an explicit signature with no **kw, so passing any of them was a type error. Add them to __init__ and configure with the types ttk.Label uses. Closes #16612 --- stdlib/tkinter/ttk.pyi | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/stdlib/tkinter/ttk.pyi b/stdlib/tkinter/ttk.pyi index bf184bc2e8f8..18232c496011 100644 --- a/stdlib/tkinter/ttk.pyi +++ b/stdlib/tkinter/ttk.pyi @@ -800,12 +800,17 @@ class Panedwindow(Widget, tkinter.PanedWindow): PanedWindow = Panedwindow class Progressbar(Widget): + # anchor, font, foreground, justify, text and wraplength need Tk 9.0. def __init__( self, master: tkinter.Misc | None = None, *, + anchor: Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"] = ..., class_: str = "", cursor: tkinter._Cursor = "", + font: _FontDescription = ..., + foreground: str = "", + justify: Literal["left", "center", "right"] = ..., length: float | str = 100, maximum: float = 100, mode: Literal["determinate", "indeterminate"] = "determinate", @@ -814,8 +819,10 @@ class Progressbar(Widget): phase: int = 0, # docs say read-only but assigning int to this works style: str = "", takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = "", + text: float | str = "", value: float = 0.0, variable: tkinter.IntVar | tkinter.DoubleVar = ..., + wraplength: float | str = ..., ) -> None: ... @overload @@ -823,7 +830,11 @@ class Progressbar(Widget): self, cnf: dict[str, Any] | None = None, *, + anchor: Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"] = ..., cursor: tkinter._Cursor = ..., + font: _FontDescription = ..., + foreground: str = ..., + justify: Literal["left", "center", "right"] = ..., length: float | str = ..., maximum: float = ..., mode: Literal["determinate", "indeterminate"] = ..., @@ -831,8 +842,10 @@ class Progressbar(Widget): phase: int = ..., style: str = ..., takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ..., + text: float | str = ..., value: float = ..., variable: tkinter.IntVar | tkinter.DoubleVar = ..., + wraplength: float | str = ..., ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ... From 6feb2b27d95fed77d42d5fcae31da84bfdbda075 Mon Sep 17 00:00:00 2001 From: Soujas K Date: Tue, 27 Oct 2026 18:23:13 +0000 Subject: [PATCH 2/2] Mark the ttk.Progressbar options that are new in Tcl/Tk 9.0 --- stdlib/tkinter/ttk.pyi | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/stdlib/tkinter/ttk.pyi b/stdlib/tkinter/ttk.pyi index 18232c496011..90cb3d5ba2c3 100644 --- a/stdlib/tkinter/ttk.pyi +++ b/stdlib/tkinter/ttk.pyi @@ -800,17 +800,16 @@ class Panedwindow(Widget, tkinter.PanedWindow): PanedWindow = Panedwindow class Progressbar(Widget): - # anchor, font, foreground, justify, text and wraplength need Tk 9.0. def __init__( self, master: tkinter.Misc | None = None, *, - anchor: Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"] = ..., + anchor: Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"] = ..., # new in Tcl/Tk 9.0 class_: str = "", cursor: tkinter._Cursor = "", - font: _FontDescription = ..., - foreground: str = "", - justify: Literal["left", "center", "right"] = ..., + font: _FontDescription = ..., # new in Tcl/Tk 9.0 + foreground: str = "", # new in Tcl/Tk 9.0 + justify: Literal["left", "center", "right"] = ..., # new in Tcl/Tk 9.0 length: float | str = 100, maximum: float = 100, mode: Literal["determinate", "indeterminate"] = "determinate", @@ -819,10 +818,10 @@ class Progressbar(Widget): phase: int = 0, # docs say read-only but assigning int to this works style: str = "", takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = "", - text: float | str = "", + text: float | str = "", # new in Tcl/Tk 9.0 value: float = 0.0, variable: tkinter.IntVar | tkinter.DoubleVar = ..., - wraplength: float | str = ..., + wraplength: float | str = ..., # new in Tcl/Tk 9.0 ) -> None: ... @overload @@ -830,11 +829,11 @@ class Progressbar(Widget): self, cnf: dict[str, Any] | None = None, *, - anchor: Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"] = ..., + anchor: Literal["nw", "n", "ne", "w", "center", "e", "sw", "s", "se"] = ..., # new in Tcl/Tk 9.0 cursor: tkinter._Cursor = ..., - font: _FontDescription = ..., - foreground: str = ..., - justify: Literal["left", "center", "right"] = ..., + font: _FontDescription = ..., # new in Tcl/Tk 9.0 + foreground: str = ..., # new in Tcl/Tk 9.0 + justify: Literal["left", "center", "right"] = ..., # new in Tcl/Tk 9.0 length: float | str = ..., maximum: float = ..., mode: Literal["determinate", "indeterminate"] = ..., @@ -842,10 +841,10 @@ class Progressbar(Widget): phase: int = ..., style: str = ..., takefocus: bool | Literal[0, 1, ""] | Callable[[str], bool | None] = ..., - text: float | str = ..., + text: float | str = ..., # new in Tcl/Tk 9.0 value: float = ..., variable: tkinter.IntVar | tkinter.DoubleVar = ..., - wraplength: float | str = ..., + wraplength: float | str = ..., # new in Tcl/Tk 9.0 ) -> dict[str, tuple[str, str, str, Any, Any]] | None: ... @overload def configure(self, cnf: str) -> tuple[str, str, str, Any, Any]: ...