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!
-
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.
You can install streamlit_desktop_app
via pip or Poetry. Both options ensure an easy and smooth installation process.
pip install streamlit_desktop_app
poetry add streamlit_desktop_app
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.
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!")
To create a standalone executable, run the following command:
streamlit-desktop-build --script example.py --name "MyStreamlitApp"
This command will:
- Build your Streamlit app into an executable.
- Place the executable in the
dist/
directory.
If you want more control over the build process, use the --pyinstaller-options
parameter. For example:
streamlit-desktop-build --script 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.
To customize the behavior of the Streamlit app, use the --streamlit-options
parameter. For example, to enable a dark theme:
streamlit-desktop-build --script example.py --name "MyStreamlitApp" --icon path/to/icon.ico --streamlit-options --theme.base=dark
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.
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
).
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.
To run desktop applications on Windows, you must have the .NET Framework (> 4.0) installed. This is required for compatibility with pywebview
.
We welcome contributions! If you have suggestions or feature requests, feel free to open an issue or submit a pull request.
-
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
This project is licensed under the MIT License. See the LICENSE file for details.
- Streamlit for its powerful framework.
- PyWebview for enabling seamless desktop integration.
- PyInstaller for making standalone executable creation a breeze.
If you have any questions or issues, feel free to reach out via GitHub Issues.