Skip to content

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

Open
soujasK wants to merge 2 commits into
python:mainfrom
soujasK:ttk-progressbar-tk9
Open

soujasK wants to merge 2 commits 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

This comment has been minimized.

@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.

@Akuli

Akuli commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

As far as I can tell, there's no good way to deal with features added in Tcl/Tk 9.0. It's still perfectly reasonable to support Tk 8.6, and there's also no good way to say "if Tcl/Tk 9.0 is available" in a stub. Ideally, the user of whatever tool uses the stub (type checker, language server, IDE, who knows) would provide some parameter to the stubs, but nothing quite like that exists.

So, I think the least bad option we have is just commenting.

Can you add a comment like # new in Tcl/Tk 9.0 at the end of the relevant lines?

@soujasK

soujasK commented Oct 27, 2026

Copy link
Copy Markdown
Author

Done. I added # new in Tcl/Tk 9.0 to each of the new options in __init__ and configure, and removed the comment above the class.

@github-actions

Copy link
Copy Markdown
Contributor

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

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

2 participants