The start_desktop_app function is the primary entry point for launching a Streamlit script within a pywebview desktop window. It manages the entire lifecycle: finding a free port, launching the Streamlit server in a background process, waiting for the server to become responsive, and opening the desktop window. When the window is closed, it ensures the Streamlit process is terminated.
Note on Configuration: The following Streamlit options are automatically overridden by the application to ensure proper desktop behavior and will be ignored if provided in the options dictionary:
server.address (set to localhost)server.port (set to a dynamically found free port)server.headless (set to true)global.developmentMode (set to false)
from streamlit_desktop_app import start_desktop_app
# Basic usage
start_desktop_app('app.py')
# Custom window size and title
start_desktop_app(
'app.py',
title='My Streamlit App',
width=1200,
height=800
)
# With additional Streamlit options (excluding overridden ones)
start_desktop_app(
'app.py',
options={
'theme.primaryColor': '#F63366',
'theme.backgroundColor': '#FFFFFF'
}
)