Closed bzqadmin closed 2 months ago
![Uploading Snipaste_2023-04-20_22-46-31.png…]()
Hello,
It looks like other people have encountered a similar problem - with a variety of different fixes.
I don't typically use pyinstaller - but I will take a look tonight and see if I can replicate the issue.
Hello,
I have found a solution to this issue - you can run the command with --collect-data TKinterModernThemes
before the filename. For example, if you were using: pyinstaller main.py
previously, you should now use pyinstaller --collect-data TKinterModernThemes main.py
.
I will update the Readme to include this relevant info, as you are certainly not the first person to have this problem. Please let me know if you run into any further issues.
Thank you, Robert Nies
I'm getting this exact same error without PyInstaller, It runs fine on Windows, but when trying to run on MacOS (newest OS), I get this error about the set theme not working. Any ideas @RobertJN64
Interesting - I test on Windows and Linux, so its possible that MacOS isn't working properly - I can check later today when I have access to a Mac.
If you want, you could changes these lines in __init__.py
try:
path = os.path.abspath(__file__ + "/../themes/" + theme.lower() + "/" + theme.lower() + ".tcl")
self.root.tk.call("source", path)
except tk.TclError:
pass #theme already loaded...
self.root.tk.call("set_theme", mode.lower())
to
path = os.path.abspath(__file__ + "/../themes/" + theme.lower() + "/" + theme.lower() + ".tcl")
self.root.tk.call("source", path)
self.root.tk.call("set_theme", mode.lower())
and report if you get a more detailed error.
Also - make sure your theme is one of "park", "azure", or "sun-valley"
I did a fresh python and TKMT install on MacOS and had no issues running the example code. I would make sure you are using one of the 3 supported themes (spelled correctly), and you haven't moved the themes
folder after install.
I did a fresh python and TKMT install on MacOS and had no issues running the example code. I would make sure you are using one of the 3 supported themes (spelled correctly), and you haven't moved the
themes
folder after install.
Hmm, rather interesting, I wrote everything on Windows, all worked properly, tried to run it on MacOS (no changes to themes folder), and it gave that error, I'll try your change and see what happens.
Edit: _tkinter.TclError: version conflict for package "Tk": have 8.5.9, need 8.6
Seems like MacOS is on a super old version? https://github.com/prati0100/git-gui/issues/26#issuecomment-574631023 This might be of some info?
Any way we can use 8.5.9 somehow? :)
I mean the preferable option would be upgrading the Tk version on your machine - especially given that mine was fine after a fresh py 3.11 install. Tk 8.5.9 is well over 10 years old at this point...
If you want to try using the old version - the only place it is specified is in the light.tcl
or dark.tcl
files for your theme.
(TKinterModernThemes\themes\park\theme\dark.tcl
)
Just change package require Tk 8.6
to package require Tk 8.5
and see if everything still loads okay. After skimming the new features of 8.6 nothing particulary stands out as critical, but there could be a reason rdbende chose 8.6.
According to python.org (https://www.python.org/download/mac/tcltk/#built-in-8-6-11)
As of Python 3.9.1, all current universal2 Python installers for macOS downloadable from python.org supply their own private copies of Tcl/Tk 8.6.11. They do not look for or use any third-party or system copies of Tcl/Tk. This is an Aqua Cocoa Tk.
I have a relatively new install of Python, 3.9.6, not sure why it's got such an old copy of TKInter (but the laptop is like 4 months old, it's an M2 Mac). I tried changing the "package require Tk 8.6" but now getting a "image file format "png" is not supported" Shame, wonder if 8.6 introduced png support?
Highlights of Tk 8.6
Built-in PNG Image Support: Photo images now support read/write in the PNG format, with the ability to set the alpha channel.
Yep - looks like PNG is only in 8.6. I would try manually installing the newest Tk version from https://www.tcl.tk/software/tcltk/download.html - I obviously can't support a version old enough that PNG images won't work.
I get the same error when compiling a file using nuitka. I decided to remove the try: except: block in init.py file on line ~64 to examine the error in more detail, and got this:
And when running the code directly, everything works fine.
I had no issues building a sample script with python -m nuitka main.py
.
When I ran python -m nuitka --onefile --enable-plugin=tk-inter main.py
this resulted in the issue you had.
I fixed it by adding --include-data-dir=venv/Lib/site-packages/TKinterModernThemes=TKinterModernThemes
so the entire command was python -m nuitka --onefile --enable-plugin=tk-inter --include-data-dir=venv/Lib/site-packages/TKinterModernThemes=TKinterModernThemes main.py
This is needed so the compiled program has access to the TCL and png files that make up TKMT.
Let me know if this fixes your issue or if you need anything else!
I had no issues building a sample script with
python -m nuitka main.py
.When I ran
python -m nuitka --onefile --enable-plugin=tk-inter main.py
this resulted in the issue you had.I fixed it by adding
--include-data-dir=venv/Lib/site-packages/TKinterModernThemes=TKinterModernThemes
so the entire command waspython -m nuitka --onefile --enable-plugin=tk-inter --include-data-dir=venv/Lib/site-packages/TKinterModernThemes=TKinterModernThemes main.py
This is needed so the compiled program has access to the TCL and png files that make up TKMT.
Let me know if this fixes your issue or if you need anything else!
Yes, that worked for me, thank you
Awesome, glad I could help.
tkintermodernthemes __init__.py line68 invalid command name set_theme
altgraph==0.17.3 pefile==2023.2.7 Pillow==9.5.0 pyinstaller==5.10.1 pyinstaller-hooks-contrib==2023.2 pywin32-ctypes==0.2.0 TKinterModernThemes==1.9.3 ttkthemes==3.2.2 typing_extensions==4.5.0