TomSchimansky / CustomTkinter

A modern and customizable python UI-library based on Tkinter
MIT License
11.23k stars 1.07k forks source link

CustomTkinter assets in wrong directory #291

Open Moeman101 opened 2 years ago

Moeman101 commented 2 years ago

When compiling a program containing customtkinter, for some reason it drops its asset folder and sits a level too deep for the program to look for. It gets compiled to site-packages but It looks for itself in one folder level higher.
below are screenshots of my solution which allows the program to successfully compile and display

Error solution Solution Part 2

felipetesc commented 2 years ago

When you say

When compiling a program containing customtkinter

you mean you are trying to execute the script, or pyinstaller? ( you need extra steps for pyinstaller) -> https://github.com/TomSchimansky/CustomTkinter/wiki/Packaging

Sometimes Windows can't figure it out how to solve long paths...

https://www.thewindowsclub.com/how-to-enable-or-disable-win32-long-paths-in-windows-11-10

You Could try to use somethings like this,

import sys
#change for your path
sys.path.append("your\\custom\\windows\\path\\to\\CustomTkinter")

I use Linux and I've never found this issue. But, yes, maybe it's something related to CTk.

Moeman101 commented 2 years ago

sorry for the ambiguity, this was when I was using auto-py-to-exe to precompile my code into a .exe

felipetesc commented 2 years ago

I can only try to guess here, since I've never used auto-py-to-exe . I imagine auto-py-to-exe doesn't automatically add assets folder and its contents inside site-packages.

What happens if you copy the assets folder and paste inside the compiled folder located at site-packages/CustomTkinter by yourself? Does it work?

Something else, are you using auto-py-to-exe to hide your app source code ? Because I achieved that using some rust libs to hide my python code, and I was thinking about working more on that so we can have another option to package and distribute ctk projects

Moeman101 commented 2 years ago

I can paste the assests folder in the location it looks for them and everything works. But there are a few wonky GUI bugs that make my app look weird.

lorelos commented 2 years ago

I have a similar problem afer compiling with pyinstaller.

Here's a doc: https://github.com/TomSchimansky/CustomTkinter/wiki/Packaging#windows-pyinstaller-auto-py-to-exe

I'm sad I can't use the --onefile option...

Traceback (most recent call last): File "customtkinter__init__.py", line 20, in File "customtkinter\theme_manager.py", line 16, in load_theme FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\MYUSER~1.USER\AppData\Local\Temp\_MEI132042\customtkinter\assets\themes\blue.json'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "\my_path\my_folder\my_file.py", line 3, in import customtkinter File "", line 1027, in _find_and_load File "", line 1006, in _find_and_load_unlocked File "", line 688, in _load_unlocked File "PyInstaller\loader\pyimod02_importers.py", line 493, in exec_module File "customtkinter__init__.py", line 22, in FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\MYUSER~1.USER\AppData\Local\Temp\_MEI132042\customtkinter\assets\themes\blue.json'

The .json theme file for CustomTkinter could not be found. If packaging with pyinstaller was used, have a look at the wiki: https://github.com/TomSchimansky/CustomTkinter/wiki/Packaging#windows-pyinstaller-auto-py-to-exe [22248] Failed to execute script 'controle_neige' due to unhandled exception! `

JoakimBrandt commented 1 year ago

Yeah, same issue over here. It really bums me out that I can't use the single file option. It ruins the experience as I don't want to send my colleagues/clients a zip file containing all of the necessary files. Is there no way at all to achieve in getting a single .exe file?