TkinterEP / ttkthemes

A group of themes for the ttk extenstions for Tkinter
GNU General Public License v3.0
364 stars 47 forks source link

ttkthemes breaks Tk #93

Open olebole opened 1 year ago

olebole commented 1 year ago

For the Debian package of ttkthemes, I got a the bug report Debian#1021389:

When this package is installed, 'tclsh' (the Tcl interpreter, provided by debian package 'tcl') becomes broken in such a way that it's no longer possible to import/load the Tk graphics/gui extension (provided by debian package 'tk').

Although I'm reporting from a Debian Stable system, this bug is happening in Ubuntu too, and this package seems obscure so I assume this may still be an issue that nobody else has noticed or fixed yet.

Steps to reproduce:

  1. Start a X windows/desktop session.
  2. Install debian packages 'tcl', and 'tk', and 'tcl-ttkthemes', perhaps with this command or similar:
      sudo apt-get install tcl tk tcl-ttkthemes
  3. Create a text file with the name 'test.tcl' and put these lines in it:
    package require Tk
    pack [ label .l -text "Debian" ]
  4. Open a terminal window and run this command:
     tclsh test.tcl
  5. Observe that this error message is printed and the script exits:
      circular package dependency: attempt to provide Tk Ϻ£ü requires Tk
      while executing "package require Tk"
        (file "test.tcl" line 1)
  6. Uninstall debian package 'tcl-ttkthemes'.
  7. Run 'tclsh test.tcl' again, and note that this time the error is not printed and the script opens a window with text "Debian" in it.

The reason for this seems the lines https://github.com/TkinterEP/ttkthemes/blob/87fa24f3cc9f78c5d4660f1a3f1b8807f6fa57fe/ttkthemes/advanced/pkgIndex.tcl#L5 and https://github.com/TkinterEP/ttkthemes/blob/87fa24f3cc9f78c5d4660f1a3f1b8807f6fa57fe/ttkthemes/png/pkgIndex.tcl#L5

which were introduced in https://github.com/TkinterEP/ttkthemes/commit/87fa24f3cc9f78c5d4660f1a3f1b8807f6fa57fe (part of #66).

Removing these lines fixes the problem; however I am not sure whether ttkthemes then still works properly. Can you check that?

RedFantom commented 1 year ago

Interesting! The Debian package is not maintained by myself, but I can certainly imagine that this is troublesome... The package require lines are not necessary for ttkthemes to work in a Python/Tkinter-context. However, I am a bit confused that ttkthemes appears to get auto-loaded when loading Tk. That's where I would imagine the circular-import error comes from.

I think that might be because of this file (Disclaimer: I have never actually built Debian packages from scratch!)

Either you'd have to file some bug report with the maintainer of the Debian package. Otherwise, I'll consider removing the lines. The reason they're there is enforce Tk 8.6 over, say, Tk 8.5 (shipped with Python 2.7). Let me know your thoughts, and in case you find where to open a bug report with the maintainers, I can opine over there as well.

Edit: I should improve my reading skills 🤦🏻‍♂️ . Sorry, I did not immediately realize that you are actually the packager for Debian (#77). There are two options, I think. Either:

  1. The package require line is removed, making the non-support for Python 2.7/Tk <8.6 implicit
  2. ttkthemes is no longer auto-loaded when Tk is loaded, which I think can be implemented by updating the Debian package

Personally, I am in favour of option 2.

olebole commented 1 year ago

I added the pkgIndex.tcl in the Debian package to make ttkthemes easily loadable in SAOImageDS9 with package require ttk::theme::XXX, for which it is a dependency. Since Debian only supports Tcl8.6 and Python 3, I'd prefer option 1, and could remove the package require lines also locally in the Debian package. However, it may be that I misunderstood something and there is a better solution than my hand-made pkgIndex.tcl.