GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-124111: Update tkinter for compatibility with Tcl/Tk 9.0.0 by culler · Pull Request #124156 · python/cpython

Conversation

@culler

@culler culler commented Sep 17, 2024 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

This PR updates tkinter, ttk, test.test_tkinter and test.test_ttk to make them work and pass tests when built against either TclTk 8.6.15, which was released today, or TclTk 9.0.0 which currently has a release candidate and will be released soon. The changes to the tests include some re-organization to make it easier to accommodate expected development of Tk 9, particularly with respect to the new TclObject of type "pixels" used in Tk 9 for options whose values represent screen distances.

Please also see the discussion on PR #124112.

Note that, unlike #124112, this PR targets Python 3.14.

  • Issue: Update tkinter to use Tk 8.6.15 or (better) Tk 9.0 #124111

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
culler added 2 commits September 16, 2024 18:14
@culler
New branch for PR against Python 3.14.
797ab58
@culler
Ttk tests on linux
03ccc1b
@bedevere-app bedevere-app Bot added the awaiting review label Sep 17, 2024
@bedevere-app bedevere-app Bot mentioned this pull request Sep 17, 2024
Update tkinter to use Tk 8.6.15 or (better) Tk 9.0 #124111
Closed
@bedevere-app

bedevere-app Bot commented Sep 17, 2024

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@culler
Remove trailing whitespace.
d7fdc88
@bedevere-app

This comment was marked as duplicate.

Sign in to view
culler added 2 commits September 17, 2024 10:39
@culler
Add NEWS file.
9fe5e01
@culler
Make Windows build work; adjust for new changes to Canvas.
144c754
@culler
culler requested a review from a team as a code owner September 19, 2024 16:11
zooba
zooba reviewed Sep 19, 2024
View reviewed changes

@zooba zooba left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know why your generated files look like they're completely changed? It is line endings being bad? (I believe our regen scripts assume you're using autocrlf on Windows.)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread PCbuild/tcltk.props Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread PCbuild/tcltk.props Resolved

Uh oh!

There was an error while loading. Please reload this page.

@culler
Attempt to restore autogenerated files that git tricked me into commi…
3b21086
…tting.
@culler

culler commented Sep 19, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

Do you know why your generated files look like they're completely changed? It is line endings being bad? (I believe our regen scripts assume you're using autocrlf on Windows.)

I have no idea. I committed those by mistake, since I am used to using git commit -a. It has something to do with Windows - those files were not changed by other platforms.

I think I have now restored the autogenerated files that I committed by mistake.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@culler
Revert other autogenerated files committed by mistake
485e38a
zware
zware reviewed Sep 19, 2024
View reviewed changes

@zware zware left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! I have some comments that are mostly style nits, and I think we may want to hold off on the changes to PCbuild/. I don't think we'll be able to move the Windows builds for <=3.13 to Tcl/Tk 9 (at least not immediately), so it will make backporting the other changes easier to leave the 3.14 PCbuild/ updates to a separate PR.

Thanks!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/test/test_tkinter/test_misc.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_tkinter/test_widgets.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_tkinter/widget_tests.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_ttk/test_widgets.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

culler added 7 commits September 19, 2024 14:06
@culler
Revert one more autogenerated file committed by mistake
5a954ec
@culler
Reference for combobox issue; address conditional definitions of _cli…
50d6958
…pped and _no_round.
@culler
Revert PCbuild changes; add examples for tk 9
ee186de
@culler
Adjust no_round for Canvas and Scrollbar.
1318d04
@culler
Adjust _clipped for Canvas once more.
e68994f
@culler
Hmmm = Canvas does clip highlightthickness.
c069c89
@culler
Remove message catalog.
8072c54
@culler

culler commented Sep 20, 2024

Copy link
Copy Markdown
Contributor Author

I think I have now addressed all issues raised in the comments. Is there anything else that is needed?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@culler
culler requested a review from zware September 20, 2024 16:38
@culler
Force checks to rerun since CLA signing seems hung. (No changes.)
ec56443
@culler
culler force-pushed the tk9_for_python314 branch from 8072c54 to ec56443 Compare September 21, 2024 02:06
@zooba

zooba commented Sep 23, 2024

Copy link
Copy Markdown
Member

We don't want example files in the build directory. To "save" the changes for later, they could either be a draft PR, comments in the file (not preferred), or you could add the changes with Condition="$(TclMajorVersion) == '9'" checks so that they automatically apply when building against 9.0 (preferred).1

Footnotes

  1. Number comparisons are a bit wonky in MSBuild, so usually just best to pick the most sensible default. In this case, it's probably actually to check $(TclMajorVersion) == '8' for the old behaviour, so that when 10.0 comes out it'll get the newer behaviours. ↩

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@culler

culler commented Sep 23, 2024

Copy link
Copy Markdown
Contributor Author

We don't want example files in the build directory. To "save" the changes for later, they could either be a draft PR, comments in the file (not preferred), or you could add the changes with Condition="$(TclMajorVersion) == '9'" checks so that they automatically apply when building against 9.0 (preferred).1

Footnotes

1. Number comparisons are a bit wonky in MSBuild, so usually just best to pick the most sensible default. In this case, it's probably actually to check `$(TclMajorVersion) == '8'` for the old behaviour, so that when 10.0 comes out it'll get the newer behaviours. [↩](#user-content-fnref-1-9d9cf4f3af8602fa729bad031ef1ba2c)

Sure. I will attempt to modify _tkinter.vcxproj to allow building against either 8.6.14 or 9.0.0. (Note that 8.6.15 has been released, but the binaries are not available to get_externals.bat yet.)

zware reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

culler added 2 commits September 23, 2024 11:39
@culler
Merge branch 'tk9_for_python314' of github.com:culler/cpython into tk…
4f753f8
…9_for_python314
@culler
Update build files to use Tcl/Tk 8.6.14 by default but to allow any v…
bf2243f
…ersion by setting the TclVersion environment variable
@culler

culler commented Sep 25, 2024

Copy link
Copy Markdown
Contributor Author

I think this PR is finished. The PR checks test against Tcl/Tk 8.6.14, and they are showing no failures. I have tested against Tcl/Tk 8.6.15 and Tcl/Tk 9.0.0 (rc2) on my own machines, running Ubuntu 22.04, Windows 11, and macOS 14. There are no failures in those 6 cases. The issue reported in #124378 with 8.6.15 has been resolved here.

The release of Tcl/Tk 9.0.0 is expected within a week, and surely will happen by the end of next week.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

zware
zware approved these changes Sep 25, 2024
View reviewed changes

@zware zware left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thank you! I'm satisfied with this change overall, but I think we should get a once-over from @serhiy-storchaka for the tkinter changes and a final confirmation from @zooba that the PCbuild/ changes match his expectations.

With your permission, I'd like to extract your ttk Notebook test fixes to a separate PR so that we can go ahead with it and get it backported. (If you would prefer to make that split yourself, that works for me.)

I expect that we will eventually be backporting this whole PR even if we don't start shipping 9.0 with our <3.14 binaries because at some point our non-Windows CI systems will inevitably update to 9.0, but I'm not sure how quickly that will happen and want to be sure we get 8.6.15 supported as soon as we can.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread Lib/test/test_tkinter/test_misc.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread Lib/test/test_tkinter/support.py Outdated

pix_re = re.compile(r'[0-9]*\.?[0-9]*[cimp]{1}')
def is_pixel_str(x):
return pix_re.fullmatch(x) != None

@zware zware Sep 25, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this doesn't seem to be used anymore.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels Sep 25, 2024
@culler
Include changes suggested by @zware
5edecc1
@culler

culler commented Sep 25, 2024

Copy link
Copy Markdown
Contributor Author

This is great, thank you! I'm satisfied with this change overall, but I think we should get a once-over from @serhiy-storchaka for the tkinter changes and a final confirmation from @zooba that the PCbuild/ changes match his expectations.

Thanks! That sounds good,

With your permission, I'd like to extract your ttk Notebook test fixes to a separate PR so that we can go ahead with it and get it backported. (If you would prefer to make that split yourself, that works for me.)

By all means. I would prefer to have you handle the split.

I expect that we will eventually be backporting this whole PR even if we don't start shipping 9.0 with our <3.14 binaries because at some point our non-Windows CI systems will inevitably update to 9.0, but I'm not sure how quickly that will happen and want to be sure we get 8.6.15 supported as soon as we can.

Great!

zware and Wulian233 reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@culler
culler requested a review from zooba September 25, 2024 18:29
@zware
zware requested a review from serhiy-storchaka September 25, 2024 18:36
@zware zware mentioned this pull request Sep 25, 2024
gh-124378: Update test_ttk for Tcl/Tk 8.6.15 #124542
Merged
@culler

culler commented Sep 25, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

According to this email the release of Tcl/Tk 9.0.0.0 will happen tomorrow.

Addendum: Tcl/Tk 9.0.0.0 were in fact released today 2/26/2024 as scheduled.

serhiy-storchaka reacted with hooray emoji
All reactions
  • 🎉 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@zware
Merge branch 'main' into tk9_for_python314
f661969
zooba
zooba reviewed Sep 27, 2024
View reviewed changes

@zooba zooba left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Along with the MSI changes (and possibly under PC/layout as well, I haven't checked), we need to make sure that we're okay with redistributing libtommath.dll and also that there isn't a static linking option for it. zlib unfortunately causes us trouble, but static linking here is impossible (because Tcl/Tk doesn't allow for it in their build scripts - I suspect the same will apply to tommath).

I'm okay with merging without the MSI changes, but we then cannot update any releases until it's done. As annoying as it is for backports, I'd require a comment in get_externals.bat to this effect.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread PCbuild/_tkinter.vcxproj Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread PCbuild/tcltk.props Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread PCbuild/tcltk.props
<tcltkDir Condition="$(tcltkDir) == ''">$(ExternalsDir)tcltk-$(TclVersion)\$(ArchName)\</tcltkDir>
<tclWin32Exe Condition="$(Platform) == 'Win32'">$(tcltkDir)\bin\tclsh$(TclMajorVersion)$(TclMinorVersion)t.exe</tclWin32Exe>
<tclWin32Exe Condition="$(Platform) != 'Win32'">$(tcltkDir)\..\win32\bin\tclsh$(TclMajorVersion)$(TclMinorVersion)t.exe</tclWin32Exe>
<tclExternalTommath Condition="$(TclMajorVersion) == '9'">TCL_WITH_EXTERNAL_TOMMATH;</tclExternalTommath>

@zooba zooba Sep 27, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not used anywhere, just remove it.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@culler culler Sep 29, 2024

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the TCL_WITH_EXTERNAL_TOMMATH constant is used when building against TclTk 9.0; although it is not used by 8.6. With 9.0, if it is not defined then all of the symbols defined in libtommath.dll are reported by the linker as being undefined. I believe that this is related to how the Tcl stubs library works; it is not a straightforward linker error since libtommath.dll is being passed to the linker.

One might hope that the existence of a constant named TCL_WITH_EXTERNAL_TOMMATH indicates that one could choose not to have an external libtommath.dlll and instead arrange for libtommath to be statically linked into libtcl.dll, as is the case with Tcl 8.6. However, I was not able to find a combination of build options which accomplished that. I will try to find out if it is possible.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@culler culler Sep 30, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zooba: As far as I can tell. the following command uses MSVC to build a static library tcl90s.lib which has both zlib and (part of) libtommath built-in:
nmake -f makefile.vc TCL_WITH_INTERNAL_ZLIB=1 TCL_WITH_EXTERNAL_TOMMATH=0 STATIC_BUILD=1

According to dumpbin, the tclsh90s.exe executable built by that command does not have libtommath.dll or zlib.dll as dependencies. So presumably the same would be true of the _tkinter extension if it were linked against tcl90s.lib.

If you are willing to use gcc in msys64 then configure --disable-static seems to do the equivalent thing.

Reference: https://core.tcl-lang.org/tips/doc/trunk/tip/538.md

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
culler and others added 5 commits September 29, 2024 13:36
@culler
Add changes to tcltk.props and _tkinter.vcxproj suggested by @zooba
822c3bf
@culler
Merge branch 'tk9_for_python314' of github.com:culler/cpython into tk…
7d851a8
…9_for_python314
@culler
Merge branch 'main' into tk9_for_python314
635d807
@zware
Merge remote-tracking branch 'origin/main' into tk9_for_python314
ba09108
@zware
Formatting fixups, remove note from build.bat
9075a80
It's not really the place to call out TclVersion particularly.  We
probably should have a note about environment variables somewhere,
but I don't have a good wording for it at the moment.  We can add
that later on.
@zware zware changed the title gh-124111 Update tkinter to use TclTk 8.6.15 or 9.0.0 gh-124111: Update tkinter for compatibility with Tcl/Tk 9.0.0 Nov 14, 2024
@zware
zware merged commit 47cbf03 into python:main Nov 14, 2024
@bedevere-app bedevere-app Bot removed the awaiting merge label Nov 14, 2024
@oehhar

oehhar commented Nov 15, 2024

Copy link
Copy Markdown

Big applause to Marc for this big bunch of work. I am sure, the TkInter community will enjoy tk 9.0, as it has a better look and scaling ability of the whole gui.
Harald with greeting from the Tcl/Tk team !

Xiaokang2022 and hugovk reacted with hooray emoji
All reactions
  • 🎉 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@TransparentLC TransparentLC mentioned this pull request Nov 18, 2024
项目中用到的tkinter(tcl和tk)可否更新到兼容9.0大版本,目前项目需要的是8.6大版本 TransparentLC/realesrgan-gui#91
Open
@bedevere-app

bedevere-app Bot commented Nov 28, 2024

Copy link
Copy Markdown

GH-127364 is a backport of this pull request to the 3.13 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

vstinner pushed a commit to vstinner/cpython that referenced this pull request Nov 28, 2024
@culler @vstinner
pythongh-124111: Update tkinter for compatibility with Tcl/Tk 9.0.0 (p…
8eb4d00
…ythonGH-124156)

(cherry picked from commit 47cbf03)
@vstinner

vstinner commented Nov 29, 2024

Copy link
Copy Markdown
Member

I propose to backport this change to Python 3.13, see: #127364.

See the discussion on the issue for the backport rationale.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

picnixz pushed a commit to picnixz/cpython that referenced this pull request Dec 8, 2024
@culler @picnixz
pythongh-124111: Update tkinter for compatibility with Tcl/Tk 9.0.0 (p…
a693262
…ythonGH-124156)
@culler culler mentioned this pull request Jan 10, 2025
In linux, copying a tkinter font doubles its size when using Tk 8.6 and a hi-res screen. #128719
Closed
ebonnal pushed a commit to ebonnal/cpython that referenced this pull request Jan 12, 2025
@culler @ebonnal
pythongh-124111: Update tkinter for compatibility with Tcl/Tk 9.0.0 (p…
9184030
…ythonGH-124156)
@serhiy-storchaka serhiy-storchaka mentioned this pull request Jul 10, 2026
[3.13] gh-128846: Make tkinter tests robust against Tcl/Tk 9.0 #153484
Merged
serhiy-storchaka added a commit that referenced this pull request Jul 11, 2026
@serhiy-storchaka
[3.13] gh-128846: Make tkinter tests robust against Tcl/Tk 9.0 (GH-15…
59e183c
…3484)

Backport the test-only parts of the Tcl/Tk 8.7/9.0/9.1 test adaptations so
that test_tkinter and test_ttk pass when Python 3.13 is built against
Tcl/Tk 9.0 (for example the Homebrew build used on macOS), while still
passing against the Tcl/Tk 8.6 that 3.13 ships.

Combines the test changes from:

* gh-124111: Update tkinter for compatibility with Tcl/Tk 9.0.0 (GH-124156)
* gh-124111: test macOS CI with Tk 9 (GH-137424)
* gh-145736: Fix Tkinter tests for Tk 8.7, 9.0 and 9.1 (GH-145738)

The corresponding non-test changes (Modules/_tkinter.c, Lib/tkinter/ttk.py,
PCbuild and CI configuration) are not backported.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@zooba zooba zooba left review comments
@zware zware zware approved these changes
@serhiy-storchaka serhiy-storchaka Awaiting requested review from serhiy-storchaka

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@culler @zooba @zware @oehhar @vstinner
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.