CustomTkinter icon indicating copy to clipboard operation
CustomTkinter copied to clipboard

__init__.py loading default theme does not work with pyinstaller --onefile

Open elliott-turner opened this issue 3 years ago • 2 comments

The following line loads the default theme... https://github.com/TomSchimansky/CustomTkinter/blob/22b4dfb2d33bf877c96c316afa2456f28bcd560a/customtkinter/init.py#L17

If you use pyinstaller with the --onefile option you will most likely get a FileNotFoundError with a message indicating that blue.json does not exist. There is a fix for this that can be used within your code that can be found here, however, even if you use your own theme file or load one of the default theme files using this fix in your code, the error persists as the __init__.py file will always try to first load blue.json on its own.

With that said, would it be possible to move loading a default theme out of __init__.py so it can be done "differently" if need be? Is there another way someone would suggest suppressing this issue?

Thanks to everyone who has been contributing to this project, Tkinter has needed something exactly like this for a long time in my opinion.

elliott-turner avatar Jun 20 '22 20:06 elliott-turner

I cannot move ThemeManager.load_theme("blue") out of the init file, but I surrounded it with a try except block. So when you load a theme again in your own main file with the fixed path you mentioned it should work.

TomSchimansky avatar Jul 01 '22 20:07 TomSchimansky

Yep, I think that does the trick. Thanks!

elliott-turner avatar Jul 04 '22 04:07 elliott-turner