Replies: 1 comment
-
Sorry for necroposting, but I've just came up to this discussion from Google while facing the same problem. And as long as this is a question, not an answer, I had to figure out the way. So here is solution if someone else stumbles upon similar issue.
Solution for Textualize/Trogon. For main Textualize it is probably very similar, you just want to adjust instantiated class name from Trogon to something else (probably Textualize):
import sys
from pathlib import Path
# this one is what I use and import
from trogon import tui, Trogon
# frozen attribute indicates packaged (compiled) app
def get_application_root() -> str:
if getattr(sys, 'frozen', False):
return os.path.dirname(sys.executable)
return str(Path(__file__).parent)
# This should be placed before @tui decorator in my case
# and for Textualize this should come before App instantiation
# [!] Don't forget to adjust value of the tcss/scss file
Trogon.CSS_PATH = os.path.join(get_application_root(), 'trogon.scss') Now after |
Beta Was this translation helpful? Give feedback.
-
Hi,
I want to package my application based on the
textual
GUI framework into a single executable file. For this I want to usePyInstaller
and a dedicatedspec
file. My project tree looks like this:Within my
application.py
I use the following relevant code to set theCSS_PATH
attribute oftextual
'sApp
class:The build runs well (no errors and no warnings) and creates the executable file within the respective
dist
folder:In order to be certain to have the configurable files (one configuration file and one CSS file used by
textual
) where the executable looks for them, I copy them over from thesrc
folder to thedist
folder.Now, after walking into the
dist
folder and starting theapplication.exe
, I get the following error message bytextual
:For me, it looks like
textual
does not look for the CSS file within the source module's folder and not look for it within the current folder when executingapplication.exe
. But it looks in the temporary folder wherePyInstaller
causes the respective files to be treated as within the "base" folder.So, I identify the "base" folder
PyInstaller
uses and telltextual
to look in there for the CSS file:And additionally, tell
PyInstaller
to deposit the CSS file within the base folder when creating the executable file:But still, textual does not find the CSS file but continues to output the following:
Is there a way to tell
textual
to look for a CSS file within the same folder as where the executable file is located when defining it's location viaCSS_PATH
attribute?Beta Was this translation helpful? Give feedback.
All reactions