Easily convert Streamlit apps into standalone desktop applications.
Project description
Streamlit Desktop App
Seamlessly transform your Streamlit apps into standalone desktop applications. This library enables you to run your web-based Streamlit projects in native desktop windows, providing a polished and intuitive user experience—no browser required!
🚀 Features
-
Effortless Deployment
With built-in PyInstaller support, convert your Streamlit app into a standalone executable in just one command. -
Native Desktop Experience
Run your Streamlit app in a native desktop window for a true desktop-like feel. -
Automatic Cleanup
The Streamlit process ends automatically when the desktop window is closed, ensuring no lingering background processes.
📖 Quick Start
Installation
You can install streamlit_desktop_app via pip or Poetry. Both options ensure an easy and smooth installation process.
Using pip
pip install streamlit-desktop-app
Using Poetry
Important Note: Due to PyInstaller's current limitations, ensure your pyproject.toml specifies a compatible Python version range:
python = "^3.10,<3.14"
Then install the package:
poetry add streamlit-desktop-app
Verify the Installation
To verify the installation, run the following command:
python -m streamlit-desktop-app
This will open a desktop window with a pre-built Streamlit app that includes a simple layout demonstrating the library's capabilities.
🎨 Create and Build Your App
Step 1: Create an Example App
Start by creating a simple example.py file:
import streamlit as st
st.title("Streamlit Desktop App Example")
st.write("This is a simple example running in a desktop window!")
st.button("Click me!")
Step 2: Build Your App into an Executable
To create a standalone executable, run the following command:
streamlit-desktop-app build example.py --name MyStreamlitApp
This command will:
- Build your Streamlit app into an executable.
- Place the executable in the
dist/directory.
Advanced Options
Example with PyInstaller Options
If you want more control over the build process, use the --pyinstaller-options parameter. For example:
streamlit-desktop-app build example.py --name MyStreamlitApp --icon path/to/icon.ico --pyinstaller-options --onefile --noconfirm
--onefile: Packages everything into a single executable.--noconfirm: Suppresses confirmation prompts during the build.
Example with Streamlit Options
To customize the behavior of the Streamlit app, use the --streamlit-options parameter. For example, to enable a dark theme:
streamlit-desktop-app build example.py --name MyStreamlitApp --icon path/to/icon.ico --streamlit-options --theme.base=dark
🛠 Advanced: Launch Programmatically
If you prefer programmatic control, use the start_desktop_app function to launch your app in a desktop window:
from streamlit_desktop_app import start_desktop_app
start_desktop_app("example.py", title="My Streamlit Desktop App")
This method is useful for:
- Embedding additional logic before launching your app.
- Development and testing.
API Reference
start_desktop_app
start_desktop_app(script_path, title="Streamlit Desktop App", width=1024, height=768, options=None)
script_path(str): Path to the Streamlit script to be run.title(str): Title of the desktop window (default: "Streamlit Desktop App").width(int): Width of the desktop window (default: 1024).height(int): Height of the desktop window (default: 768).options(dict): Additional Streamlit options (e.g.,server.enableCORS).
Manually Run PyInstaller
If you prefer manual control, use PyInstaller directly to build your app:
pyinstaller --collect-all streamlit --copy-metadata streamlit --name "MyStreamlitApp" --onefile --windowed --splash path/to/splash_image.png -i path/to/icon.ico example.py
--collect-all: Includes all static files and resources required by Streamlit.--copy-metadata: Ensures the metadata for Streamlit is included.--onefile: Packages everything into a single executable.--splash: Displays a splash screen while the app initializes.
⚠️ Important for Windows Users
To run desktop applications on Windows, you must have the .NET Framework (> 4.0) and Edge Webview2 installed. This is required for compatibility with pywebview.
Installation Steps:
- .NET Framework:
- Download and install the latest version of the .NET Framework from the official Microsoft website if it’s not already installed.
- Verify the installation by checking your system's installed programs list or using the
dotnet --infocommand in the command prompt.
- Edge Webview2:
- Download and install Edge Webview2 from the official Microsoft page.
🤝 Contributing
We welcome contributions! If you have suggestions or feature requests, feel free to open an issue or submit a pull request.
Development Setup
-
Clone the repository:
git clone https://github.com/ohtaman/streamlit-desktop-app.git
-
Install dependencies with Poetry:
poetry install -
Run the tests to ensure everything works as expected:
poetry run pytest
📜 License
This project is licensed under the Apache-2.0 License. See the LICENSE file for details.
🎉 Acknowledgments
- Streamlit for its powerful framework.
- PyWebview for enabling seamless desktop integration.
- PyInstaller for making standalone executable creation a breeze.
Contact
If you have any questions or issues, feel free to reach out via GitHub Issues.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file streamlit_desktop_app-0.3.4.tar.gz.
File metadata
- Download URL: streamlit_desktop_app-0.3.4.tar.gz
- Upload date:
- Size: 13.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8b9d62ff42fb0670bc14b161625009149b836389d60f809089fd4eb1df8799c
|
|
| MD5 |
11509455dd5a0c969ebe737a1f43bfd2
|
|
| BLAKE2b-256 |
c1e848b8fe5407c9621a6bfe13d5c5cb657ba8559aeb576268706037d17c1cbf
|
Provenance
The following attestation bundles were made for streamlit_desktop_app-0.3.4.tar.gz:
Publisher:
release.yml on ohtaman/streamlit-desktop-app
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
streamlit_desktop_app-0.3.4.tar.gz -
Subject digest:
b8b9d62ff42fb0670bc14b161625009149b836389d60f809089fd4eb1df8799c - Sigstore transparency entry: 155288522
- Sigstore integration time:
-
Permalink:
ohtaman/streamlit-desktop-app@0a8dff415b51d95388df418ee6f695dca3b3e719 -
Branch / Tag:
refs/tags/v0.3.4 - Owner: https://github.com/ohtaman
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0a8dff415b51d95388df418ee6f695dca3b3e719 -
Trigger Event:
push
-
Statement type:
File details
Details for the file streamlit_desktop_app-0.3.4-py3-none-any.whl.
File metadata
- Download URL: streamlit_desktop_app-0.3.4-py3-none-any.whl
- Upload date:
- Size: 13.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5bd5d914666bda8590128095b953615c7b6a90d42d0ad42c0e797bfc8c820922
|
|
| MD5 |
26c25b76f7d0508cb8653c19b3472a15
|
|
| BLAKE2b-256 |
353e716be0a71f8f9ba72e20b32a3cf18d5b773014c919217c4f7aab7f1d6cfb
|
Provenance
The following attestation bundles were made for streamlit_desktop_app-0.3.4-py3-none-any.whl:
Publisher:
release.yml on ohtaman/streamlit-desktop-app
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
streamlit_desktop_app-0.3.4-py3-none-any.whl -
Subject digest:
5bd5d914666bda8590128095b953615c7b6a90d42d0ad42c0e797bfc8c820922 - Sigstore transparency entry: 155288524
- Sigstore integration time:
-
Permalink:
ohtaman/streamlit-desktop-app@0a8dff415b51d95388df418ee6f695dca3b3e719 -
Branch / Tag:
refs/tags/v0.3.4 - Owner: https://github.com/ohtaman
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0a8dff415b51d95388df418ee6f695dca3b3e719 -
Trigger Event:
push
-
Statement type: