Skip to content

Tkinter, IDLE: Future Tcl and Tk can have differing version/patchlevel #104496

Description

@chrstphrchvz

Tk 8.7 will be compatible with both Tcl 8.7 and Tcl 9.0; there is no Tk 9.0 currently in development. The version and/or patchlevel of Tcl and Tk will not necessarily be identical, but there are places in Tkinter code which assume they are. A few examples which I am aware of:

tk_patchlevel = self.info_patchlevel()

_tk_patchlevel = tcl.info_patchlevel()

_tk_patchlevel = tcl.info_patchlevel()

Linked PRs

Activity

  1. terryjreedy commented on May 15, 2023

    @terryjreedy
    Member

    Is there different code to get tk version/patchlevel?

  2. chrstphrchvz commented on May 15, 2023

    @chrstphrchvz
    ContributorAuthor

    Tcl version: tkinter.Tcl().tk.call('info', 'tclversion') and tkinter.Tcl().globalgetvar('tcl_version')
    Tcl patchlevel: tkinter.Tcl().tk.call('info', 'patchlevel') and tkinter.Tcl().globalgetvar('tcl_patchLevel')
    Tk version: tkinter.Tk().globalgetvar('tk_version')
    Tk patchlevel: tkinter.Tk().globalgetvar('tk_patchLevel')

    This issue is likely more applicable to version checks which need to be added (e.g. for issues like #104497) rather than existing ones (since checking for Tcl 8.6 is sufficient for knowing e.g. whether Tk has PNG support).

    For this issue, I am less inclined to propose a solution on my own without prior input. I hesitate to introduce more ways to retrieve the version/patchlevel. Personally, I try to rely on the Tcl package vcompare command rather than retrieve/expose the version/patchlevel and attempt to reimplement correct version comparison logic in Python or Perl.

  3. terryjreedy commented on May 17, 2023

    @terryjreedy
    Member

    https://github.com/python/cpython/blob/48b3617de491f00a3bf978b355074cc8e228d61b/Lib/tkinter/__init__.py#LL1081C1-L1084C1 has the following, which includes all 'patchlevel' occurrences in the file.

        def info_patchlevel(self):  # Method of Misc, a base for toplevel and widgets. [comment added]
            """Returns the exact version of the Tcl library."""
            patchlevel = self.tk.call('info', 'patchlevel')
            return _parse_version(patchlevel)

    Is this call, the one that IDLE currently uses, returning the tcl or tk version?

  4. chrstphrchvz commented on May 17, 2023

    @chrstphrchvz
    ContributorAuthor

    https://github.com/python/cpython/blob/48b3617de491f00a3bf978b355074cc8e228d61b/Lib/tkinter/__init__.py#LL1081C1-L1084C1 has the following, which includes all 'patchlevel' occurrences in the file.

        def info_patchlevel(self):  # Method of Misc, a base for toplevel and widgets. [comment added]
            """Returns the exact version of the Tcl library."""
            patchlevel = self.tk.call('info', 'patchlevel')
            return _parse_version(patchlevel)

    Is this call, the one that IDLE currently uses, returning the tcl or tk version?

    This always returns the Tcl patchlevel.

  5. added 2 commits that reference this issue on May 17, 2023
  6. added a commit that references this issue on May 17, 2023
  7. added a commit that references this issue on May 17, 2023
  8. added a commit that references this issue on May 18, 2023
  9. terryjreedy commented on May 30, 2023

    @terryjreedy
    Member

    I am not familiar with tcl in general, just enough to translate tk commands into tkinter. Are the 'package' commands available with the tcl we install with Windows and macOS?

  10. chrstphrchvz commented on May 31, 2023

    @chrstphrchvz
    ContributorAuthor

    Are the 'package' commands available with the tcl we install with Windows and macOS?

    Yes.

  11. 7 remaining items

  12. added a commit that references this issue on Aug 7, 2023
  13. added 2 commits that reference this issue on Aug 7, 2023
  14. added a commit that references this issue on Aug 16, 2023
  15. hugovk commented on Nov 10, 2023

    @hugovk
    Member

    Anything left to do here, or can we close the issue?

  16. chrstphrchvz commented on Nov 10, 2023

    @chrstphrchvz
    ContributorAuthor

    I think it is still too early to know what else needs to be done for this issue. I am not aware of any official announcement from Tcl/Tk on what their plan is now, but some of its inner developer circle still insists that Tk 9.0 be released and not Tk 8.7.

  17. chrstphrchvz commented on Nov 28, 2023

    @chrstphrchvz
    ContributorAuthor

    The latest I have heard is that they want to release Tcl 9.0 and Tk 9.0 first, and then Tcl 8.7 and Tk 8.7 either later or not at all. I would still suggest version checks be careful about which of 8.6/8.7/9.0, Tcl or Tk, and “patchlevel” or “version” to check.

  18. dkfellows commented on Nov 28, 2023

    @dkfellows

    Tcl 9.0 will definitely ship before Tcl 8.7 (which is a "maybe, if there's demand great enough and developer effort enough"). Tk is a bit less certain, but there's a bit of head of steam getting up to go to 9.0 there too just so we can delete some really old and nasty undocumented cruft that I truly hope you're not depending on.

    We test Tcl 9.0 and Tk 8.7 as a combination, as well as Tcl 9.0 and Tk 9.0. We do not test Tcl 8.7 with Tk 9.0. Test result summaries are online.


    The proper, official methods for getting the version of Tk are:

    • set tk_version — returns 8.6, 8.7, 9.0 (i.e., just major.minor).
    • set tk_patchLevel — returns 8.6.12, 8.7a3, 9.0b1 (i.e., major.minor.patch with possible alpha/beta indicator)
    • package require Tk — returns 8.6.12, 8.7a3, 9.0b1 (same semantics as above, and loads the package if it wasn't already present)
    • In the shell script tkConfig.sh (which should be installed in any binary installation of Tk, possibly with an alternate name if there are Linux distributions about) there will be some variables like this:
      TK_VERSION='9.0'
      TK_MAJOR_VERSION='9'
      TK_MINOR_VERSION='0'
      TK_PATCH_LEVEL='b1'
      I think you can figure out what they mean. They're the only supported method (that I'm aware of) for getting the version without loading the Tk package in a Tcl interpreter. In particular, tkConfig.sh is intended for use during setting up a build process that depends on Tk.

    There are equivalents for Tcl, as well as info tclversion and info patchlevel. (I don't know why we never made tk patchlevel or tk version.)

  19. chrstphrchvz commented on Nov 29, 2023

    @chrstphrchvz
    ContributorAuthor

    The proper, official methods for getting the version of Tk are:

    • set tk_version — returns 8.6, 8.7, 9.0 (i.e., just major.minor).
    • set tk_patchLevel — returns 8.6.12, 8.7a3, 9.0b1 (i.e., major.minor.patch with possible alpha/beta indicator)
    • package require Tk — returns 8.6.12, 8.7a3, 9.0b1 (same semantics as above, and loads the package if it wasn't already present)

    In Python syntax, the first two are still probably better done as e.g. tkinter.Tk().globalgetvar('tk_version') (which relies on Tcl_GetVar2Ex()) as in my above comment rather than trying to directly translate the Tcl syntax into tkinter.Tcl().tk.call('set', 'tk_version') or tkinter.Tcl().tk.eval('set tk_version').

    • In the shell script tkConfig.sh (which should be installed in any binary installation of Tk, possibly with an alternate name if there are Linux distributions about) there will be some variables like this:

      TK_VERSION='9.0'
      TK_MAJOR_VERSION='9'
      TK_MINOR_VERSION='0'
      TK_PATCH_LEVEL='b1'

      I think you can figure out what they mean. They're the only supported method (that I'm aware of) for getting the version without loading the Tk package in a Tcl interpreter. In particular, tkConfig.sh is intended for use during setting up a build process that depends on Tk.

    The only times I am aware that Tkinter needs to know Tcl/Tk versions without an interpreter are when configuring and compiling. But that is done using the macros from <tcl.h> and <tk.h>, after either providing the right Tcl/Tk compiler flags to the configure script or by using pkg-config (which is what many other FOSS projects use; Tcl/Tk provides much less via pkg-config than in tclConfig.sh/tkConfig.sh, but with https://core.tcl-lang.org/tcl/info/4b11db28e63d there now seems to be just enough for Tkinter to build).

  20. terryjreedy commented on Nov 29, 2023

    @terryjreedy
    Member

    Has it been determined whether tcl/tk 9 will have full unicode support? Is there any approximate target date?

  21. terryjreedy commented on Sep 16, 2024

    @terryjreedy
    Member

    In #124111 , Mark Culler, member of the Tcl Core Team (TCT), says "The TclTk project has decided that there will be no release of the 8.7 branches." and "8.6.15 and 9.0 versions of Tcl and Tk currently have release candidates, while Tcl and Tk 8.7 have never reached beta". Also, 9.0 will have full unicode support (no CESU-8).

  22. terryjreedy commented on Jan 8, 2025

    @terryjreedy
    Member

    If something else come up, we should open a new issue.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions