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.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I want to package my application based on the
textualGUI framework into a single executable file. For this I want to usePyInstallerand a dedicatedspecfile. My project tree looks like this:Within my
application.pyI use the following relevant code to set theCSS_PATHattribute oftextual'sAppclass:The build runs well (no errors and no warnings) and creates the executable file within the respective
distfolder: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 thesrcfolder to thedistfolder.Now, after walking into the
distfolder and starting theapplication.exe, I get the following error message bytextual:For me, it looks like
textualdoes 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 wherePyInstallercauses the respective files to be treated as within the "base" folder.So, I identify the "base" folder
PyInstalleruses and telltextualto look in there for the CSS file:And additionally, tell
PyInstallerto 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
textualto look for a CSS file within the same folder as where the executable file is located when defining it's location viaCSS_PATHattribute?Beta Was this translation helpful? Give feedback.
All reactions