Wednesday, May 10, 2023

PyInstaller - Include sv-ttk Sun Valley TTK Theme in build

Problem:

Trying to build a python application using tkinter and ttk Sun Valley theme using pyinstaller, the finished build would throw errors unable to find the tcl file and related theme data. Pyinstaller does a pretty good job finding and including related python files and modules, but it doesn't do so well with other assets and this theme uses other assets.


Solution:

The brute force method is just to include the tcl file and theme resources manually when building the program.

pyinstaller --onefile --noconsole --add-data "<path to python modules>\Lib\site-packages\sv_ttk\sv.tcl;sv_ttk\" --add-data "<path to python modules>\Lib\site-packages\sv_ttk\theme\*;sv_ttk\theme" .\main.py

This should produce the bundled application with the resource files all embedded where the scripts expect to find them. 


No comments: