1

As title, I used ttk in pyinstaller's onefile mode and can't execute because I include a a01.tcl file,and this file had the following codes:

source theme/a02.tcl
source theme/a03.tcl
proc set_theme {mode} {
    if {$mode == "a02"} {
        ttk::style theme use "dark"
...
...
    } elseif {$mode == "a03"} {
        ttk::style theme use "light"

and after I convert it to a executable file, It returns :

could't read file:"theme/a02.tcl" no such file or directory.

in the main code, it used

window.tk.call("set_theme", "a02")

to call the theme, so I can't use some code like base_path = sys._MEIPASS to handle it. It runs perfectly when I convert it to a directory, but it not effective in onefile mode.

  • _In theory,_ what you need to do is somehow mount the onefile packaged stuff as a virtual file system from the Tcl perspective. Which sounds one whole lot easier than it really is; there's some significant missing pieces in that solution, specifically the virtual filesystem implementation that calls back into the Python code to get the data! This is a definitely non-trivial task… – Donal Fellows Feb 24 '22 at 14:59
  • I suppose you could hack around it by extracting the file needed to a temporary location in the Python code prior to creating the `Tk` instance? (That'd be a file-to-file copy in unpacked mode, but you wouldn't need any special permissions on the resulting files so that's easy.) – Donal Fellows Feb 24 '22 at 15:34

0 Answers0