streamlit-desktop-app


Namestreamlit-desktop-app JSON
Version 0.3.4 PyPI version JSON
download
home_pagehttps://github.com/ohtaman/streamlit-desktop-app
SummaryEasily convert Streamlit apps into standalone desktop applications.
upload_time2024-12-14 07:54:06
maintainerNone
docs_urlNone
authorohtaman
requires_python!=2.7.*,!=3.0.*,!=3.1.*,!=3.13.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,!=3.7.*,!=3.8.*,>=3.9
licenseApache-2.0
keywords streamlit desktop app pywebview pyinstaller
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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

```bash
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:

```toml
python = "^3.10,<3.14"
```

Then install the package:

```bash
poetry add streamlit-desktop-app
```

### Verify the Installation

To verify the installation, run the following command:

```bash
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:

```python
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:

```bash
streamlit-desktop-app build example.py --name MyStreamlitApp
```

This command will:

1. Build your Streamlit app into an executable.
2. 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:

```bash
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:

```bash
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:

```python
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`

```python
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:

```bash
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:

1. .NET Framework:
   - Download and install the latest version of the .NET Framework from the [official Microsoft website](https://dotnet.microsoft.com/download/dotnet) if itโ€™s not already installed.
   - Verify the installation by checking your system's installed programs list or using the `dotnet --info` command in the command prompt.
2. Edge Webview2:
   - Download and install Edge Webview2 from the [official Microsoft page](https://developer.microsoft.com/microsoft-edge/webview2).

---

## ๐Ÿค Contributing

We welcome contributions! If you have suggestions or feature requests, feel free to open an issue or submit a pull request.

### Development Setup

1. Clone the repository:

   ```bash
   git clone https://github.com/ohtaman/streamlit-desktop-app.git
   ```

2. Install dependencies with Poetry:

   ```bash
   poetry install
   ```

3. Run the tests to ensure everything works as expected:

   ```bash
   poetry run pytest
   ```

---

## ๐Ÿ“œ License

This project is licensed under the Apache-2.0 License. See the [LICENSE](LICENSE) file for details.

---

## ๐ŸŽ‰ Acknowledgments

- [Streamlit](https://streamlit.io/) for its powerful framework.
- [PyWebview](https://github.com/r0x0r/pywebview) for enabling seamless desktop integration.
- [PyInstaller](https://www.pyinstaller.org/) for making standalone executable creation a breeze.

---

## Contact

If you have any questions or issues, feel free to reach out via [GitHub Issues](https://github.com/ohtaman/streamlit-desktop-app/issues).


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ohtaman/streamlit-desktop-app",
    "name": "streamlit-desktop-app",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "!=2.7.*,!=3.0.*,!=3.1.*,!=3.13.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,!=3.7.*,!=3.8.*,>=3.9",
    "maintainer_email": null,
    "keywords": "streamlit, desktop app, pywebview, pyinstaller",
    "author": "ohtaman",
    "author_email": "ohtamans@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/c1/e8/48b8fe5407c9621a6bfe13d5c5cb657ba8559aeb576268706037d17c1cbf/streamlit_desktop_app-0.3.4.tar.gz",
    "platform": null,
    "description": "# Streamlit Desktop App\n\nSeamlessly 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\u2014no browser required!\n\n---\n\n## \ud83d\ude80 Features\n\n- **Effortless Deployment**  \n  With built-in PyInstaller support, convert your Streamlit app into a standalone executable in just one command.\n\n- **Native Desktop Experience**  \n  Run your Streamlit app in a native desktop window for a true desktop-like feel.\n\n- **Automatic Cleanup**  \n  The Streamlit process ends automatically when the desktop window is closed, ensuring no lingering background processes.\n\n---\n\n## \ud83d\udcd6 Quick Start\n\n### Installation\n\nYou can install `streamlit_desktop_app` via **pip** or **Poetry**. Both options ensure an easy and smooth installation process.\n\n#### Using pip\n\n```bash\npip install streamlit-desktop-app\n```\n\n#### Using Poetry\n\n**Important Note:** Due to PyInstaller's current limitations, ensure your `pyproject.toml` specifies a compatible Python version range:\n\n```toml\npython = \"^3.10,<3.14\"\n```\n\nThen install the package:\n\n```bash\npoetry add streamlit-desktop-app\n```\n\n### Verify the Installation\n\nTo verify the installation, run the following command:\n\n```bash\npython -m streamlit-desktop-app\n```\n\nThis will open a desktop window with a pre-built Streamlit app that includes a simple layout demonstrating the library's capabilities.\n\n---\n\n## \ud83c\udfa8 Create and Build Your App\n\n### Step 1: Create an Example App\n\nStart by creating a simple `example.py` file:\n\n```python\nimport streamlit as st\n\nst.title(\"Streamlit Desktop App Example\")\nst.write(\"This is a simple example running in a desktop window!\")\nst.button(\"Click me!\")\n```\n\n### Step 2: Build Your App into an Executable\n\nTo create a standalone executable, run the following command:\n\n```bash\nstreamlit-desktop-app build example.py --name MyStreamlitApp\n```\n\nThis command will:\n\n1. Build your Streamlit app into an executable.\n2. Place the executable in the `dist/` directory.\n\n### Advanced Options\n\n#### Example with PyInstaller Options\n\nIf you want more control over the build process, use the `--pyinstaller-options` parameter. For example:\n\n```bash\nstreamlit-desktop-app build example.py --name MyStreamlitApp --icon path/to/icon.ico --pyinstaller-options --onefile --noconfirm\n```\n\n- **`--onefile`**: Packages everything into a single executable.\n- **`--noconfirm`**: Suppresses confirmation prompts during the build.\n\n#### Example with Streamlit Options\n\nTo customize the behavior of the Streamlit app, use the `--streamlit-options` parameter. For example, to enable a dark theme:\n\n```bash\nstreamlit-desktop-app build example.py --name MyStreamlitApp --icon path/to/icon.ico --streamlit-options --theme.base=dark\n```\n\n---\n\n## \ud83d\udee0 Advanced: Launch Programmatically\n\nIf you prefer programmatic control, use the `start_desktop_app` function to launch your app in a desktop window:\n\n```python\nfrom streamlit_desktop_app import start_desktop_app\n\nstart_desktop_app(\"example.py\", title=\"My Streamlit Desktop App\")\n```\n\nThis method is useful for:\n\n- Embedding additional logic before launching your app.\n- Development and testing.\n\n---\n\n## API Reference\n\n### `start_desktop_app`\n\n```python\nstart_desktop_app(script_path, title=\"Streamlit Desktop App\", width=1024, height=768, options=None)\n```\n\n- **`script_path`** (str): Path to the Streamlit script to be run.\n- **`title`** (str): Title of the desktop window (default: \"Streamlit Desktop App\").\n- **`width`** (int): Width of the desktop window (default: 1024).\n- **`height`** (int): Height of the desktop window (default: 768).\n- **`options`** (dict): Additional Streamlit options (e.g., `server.enableCORS`).\n\n---\n\n### Manually Run PyInstaller\n\nIf you prefer manual control, use PyInstaller directly to build your app:\n\n```bash\npyinstaller --collect-all streamlit --copy-metadata streamlit --name \"MyStreamlitApp\" --onefile --windowed --splash path/to/splash_image.png -i path/to/icon.ico example.py\n```\n\n- **`--collect-all`**: Includes all static files and resources required by Streamlit.\n- **`--copy-metadata`**: Ensures the metadata for Streamlit is included.\n- **`--onefile`**: Packages everything into a single executable.\n- **`--splash`**: Displays a splash screen while the app initializes.\n\n---\n\n## \u26a0\ufe0f Important for Windows Users\n\nTo run desktop applications on Windows, you must have the **.NET Framework** (> 4.0) and **Edge Webview2** installed. This is required for compatibility with `pywebview`.\n\n### Installation Steps:\n\n1. .NET Framework:\n   - Download and install the latest version of the .NET Framework from the [official Microsoft website](https://dotnet.microsoft.com/download/dotnet) if it\u2019s not already installed.\n   - Verify the installation by checking your system's installed programs list or using the `dotnet --info` command in the command prompt.\n2. Edge Webview2:\n   - Download and install Edge Webview2 from the [official Microsoft page](https://developer.microsoft.com/microsoft-edge/webview2).\n\n---\n\n## \ud83e\udd1d Contributing\n\nWe welcome contributions! If you have suggestions or feature requests, feel free to open an issue or submit a pull request.\n\n### Development Setup\n\n1. Clone the repository:\n\n   ```bash\n   git clone https://github.com/ohtaman/streamlit-desktop-app.git\n   ```\n\n2. Install dependencies with Poetry:\n\n   ```bash\n   poetry install\n   ```\n\n3. Run the tests to ensure everything works as expected:\n\n   ```bash\n   poetry run pytest\n   ```\n\n---\n\n## \ud83d\udcdc License\n\nThis project is licensed under the Apache-2.0 License. See the [LICENSE](LICENSE) file for details.\n\n---\n\n## \ud83c\udf89 Acknowledgments\n\n- [Streamlit](https://streamlit.io/) for its powerful framework.\n- [PyWebview](https://github.com/r0x0r/pywebview) for enabling seamless desktop integration.\n- [PyInstaller](https://www.pyinstaller.org/) for making standalone executable creation a breeze.\n\n---\n\n## Contact\n\nIf you have any questions or issues, feel free to reach out via [GitHub Issues](https://github.com/ohtaman/streamlit-desktop-app/issues).\n\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Easily convert Streamlit apps into standalone desktop applications.",
    "version": "0.3.4",
    "project_urls": {
        "Documentation": "https://github.com/ohtaman/streamlit-desktop-app#readme",
        "Homepage": "https://github.com/ohtaman/streamlit-desktop-app",
        "Repository": "https://github.com/ohtaman/streamlit-desktop-app"
    },
    "split_keywords": [
        "streamlit",
        " desktop app",
        " pywebview",
        " pyinstaller"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "353e716be0a71f8f9ba72e20b32a3cf18d5b773014c919217c4f7aab7f1d6cfb",
                "md5": "26c25b76f7d0508cb8653c19b3472a15",
                "sha256": "5bd5d914666bda8590128095b953615c7b6a90d42d0ad42c0e797bfc8c820922"
            },
            "downloads": -1,
            "filename": "streamlit_desktop_app-0.3.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "26c25b76f7d0508cb8653c19b3472a15",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "!=2.7.*,!=3.0.*,!=3.1.*,!=3.13.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,!=3.7.*,!=3.8.*,>=3.9",
            "size": 13723,
            "upload_time": "2024-12-14T07:54:03",
            "upload_time_iso_8601": "2024-12-14T07:54:03.325082Z",
            "url": "https://files.pythonhosted.org/packages/35/3e/716be0a71f8f9ba72e20b32a3cf18d5b773014c919217c4f7aab7f1d6cfb/streamlit_desktop_app-0.3.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c1e848b8fe5407c9621a6bfe13d5c5cb657ba8559aeb576268706037d17c1cbf",
                "md5": "11509455dd5a0c969ebe737a1f43bfd2",
                "sha256": "b8b9d62ff42fb0670bc14b161625009149b836389d60f809089fd4eb1df8799c"
            },
            "downloads": -1,
            "filename": "streamlit_desktop_app-0.3.4.tar.gz",
            "has_sig": false,
            "md5_digest": "11509455dd5a0c969ebe737a1f43bfd2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "!=2.7.*,!=3.0.*,!=3.1.*,!=3.13.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,!=3.7.*,!=3.8.*,>=3.9",
            "size": 13065,
            "upload_time": "2024-12-14T07:54:06",
            "upload_time_iso_8601": "2024-12-14T07:54:06.012188Z",
            "url": "https://files.pythonhosted.org/packages/c1/e8/48b8fe5407c9621a6bfe13d5c5cb657ba8559aeb576268706037d17c1cbf/streamlit_desktop_app-0.3.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-14 07:54:06",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ohtaman",
    "github_project": "streamlit-desktop-app",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "streamlit-desktop-app"
}
        
Elapsed time: 0.43561s