Skip to content

Add Tk 9.0 text options to ttk.Progressbar - #16618

Open
soujasK wants to merge 1 commit into
python:mainfrom
soujasK:ttk-progressbar-tk9
Open

soujasK wants to merge 1 commit into
python:mainfrom
soujasK:ttk-progressbar-tk9

Conversation

@soujasK

@soujasK soujasK commented Oct 26, 2026

Copy link
Copy Markdown

Closes #16612.

Tk 9.0 lets ttk::progressbar display a text label inside the bar and adds six options for it: anchor, font, foreground, justify, text and wraplength (Tk 9.0 man page). Compared with the Tk 8.6 page, no options were removed; these six are the only difference.

Progressbar.__init__ and configure have explicit signatures with no **kw, so code using these options is rejected on main:

from tkinter import ttk

bar = ttk.Progressbar(text="Loading", anchor="center", font=("TkDefaultFont", 10))
bar.configure(text="Done")
error: Unexpected keyword argument "text" for "Progressbar"  [call-arg]
error: Unexpected keyword argument "text" for overloaded function "configure" of "Progressbar"  [call-overload]

This PR adds the six options to both, using the same types ttk.Label uses for them.

tkinter can be built against Tk 8.6 or 9.0, and typeshed can't tell which one it is, so the options aren't version-gated. A comment notes they need Tk 9.0. On Tk 8.6, passing them is a runtime error rather than a type error, which follows typeshed's usual preference for false negatives over false positives.

Checks: tests/mypy_test.py stdlib/tkinter -p 3.10 -p 3.14, pyright, ruff, black and check_typeshed_structure.py all pass, and the example above type-checks cleanly with the change.

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 python#16612
@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@soujasK

soujasK commented Oct 26, 2026

Copy link
Copy Markdown
Author

The three failing stubtest: stdlib (ubuntu-latest, 3.11/3.12/3.13) jobs aren't caused by this change. They report email._header_value_parser.{Terminal,TokenList}.contains_token_type missing from the stub. CPython has now backported that method to the 3.11–3.13 patch releases (the runner has 3.12.16), but #16596 added it only for >= (3, 14). The Windows and macOS runners are still on older patch releases and pass, so any PR run now hits the same failure.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tkinter.ttk.Progressbar stubs are outdated for Tk 9.0

1 participant