Packaging/distributing an app

Hello! First post here. I haven’t seen any posts on this so far. Has anyone successfully distributed a Textual app? Is there a cross-platform distribution guide anyone could recommend that works with Textual? I imagine it could be easier then distributing apps based on GUI frameworks with fewer heavy platform-specific dependencies.

2 Likes

Perhaps fbs is a preferred way? It seems to handle most of the issues and possibly handling cross-platform builds via GitHub actions. Nice touch.

Manual | fman build system

I’d love to hear if anyone has actually done anything like this - aside from pip install.

Watching this post for replies. This is something I am very interested in

1 Like

Very interested in this as well. I am developing an app using Textual that I will want to distribute to non-technical people in my company. Don’t want them to have to worry about running even a simple command from the terminal, as many of them probably don’t even know what a terminal is!

Wondering if there’s any way to emulate a terminal from the browser hosted on a website, and run a Python app in it?

1 Like

WRT distributing an app, I would have thought most of the “standard” app creators would work. Eg pyinstaller, pyoxidizer, py2exe, etc.

For putting an app in the web, this sounds like textualize’s planned commercial offering so something will be possible. However, I have had success using ttyd to share a console app the web. It uses xterm.js which I believe works well with textual.

3 Likes

Yes, that’s the main reason. I have a client that asked “Hey can we get this dashboard out to clients quickly?”

I saw what a number of our clients have gone through building and packaging Electron based apps and thought… no.

Then I stumbled on to Textualize quite by accident.

Thanks @lllama . The issue with the standard app creators is the complexity to get started, cross-platform distribution, how it’s actually packaged up and delivered. The fman build system also includes functionality for license management which is a nice bonus. I have read good things while looking around.

ttyd looks neat!

Welp. I just created an account here to ask the exact same thing hehe. PyInstaller seemed promissing, but I’m not smart enough to know why it doesn’t work. It does generate the .exe, But when I try to run it it just pops up a terminal and closes really quick, not showing anything really.

At first I came here looking for answers… since no one had a working example I did some digging. I was able to build an executable on Windows of the example Calculator app. Here’s a step-by-step:

  1. Create new virtual environment for the project and install dependencies:

    mkdir CalcApp
    cd .\CalcApp\
    python -m venv venv
    .\venv\Scripts\Activate.ps1
    pip install pyinstaller "textual[dev]"
    
  2. Copy the calculator.py to your new project folder. I renamed it to main.py, but you do you: wget https://raw.githubusercontent.com/Textualize/textual/main/examples/calculator.py -o main.py

  3. Modify the app to include the CSS inline and not in a separate file. Instead of using CSS_PATH="calculator.css", use:

    CSS = """
    Screen {
        overflow: auto;
    }
    
    #calculator {
        layout: grid;
        grid-size: 4;
        grid-gutter: 1 2;
        grid-columns: 1fr;
        grid-rows: 2fr 1fr 1fr 1fr 1fr 1fr;
        margin: 1 2;
        min-height: 25;
        min-width: 26;
    }
    
    Button {
        width: 100%;
        height: 100%;
    }
    
    #numbers {
        column-span: 4;
        content-align: right middle;
        padding: 0 1;
        height: 100%;
        background: $primary-lighten-2;
        color: $text;
    }
    
    #number-0 {
        column-span: 2;
    }
    """
    

    Just so you don’t have to worry about where the css file is after building the exe.

  4. Build using pyinstaller: pyinstaller --hidden-import textual.widgets._button --hidden-import textual.widgets._static --onefile --clean .\main.py. Note: after some digging, pyinstaller was not including the widgets used by the app, thus I had to include manually using the --hidden-import option.

  5. Run the exe: .\dist\main.exe

I’m no expert in either textual or pyinstaller, so there’s probably a better way of doing things…

@michaelwills So on top of being able to build locally with pyinstaller, looks like you can build cross-platform with github actions. I haven’t tried this myself, but there are some tutorials if you google it. Here’s one blog post about it.