API reference

streamlitrunner.run(
func: Callable[[...], Any] | None = None,
funcargs: Sequence[Any] | None = None,
funckwargs: dict[str, Any] | None = None,
*,
title: str = 'Streamlit runner app',
maximized: bool = True,
open_as_app: bool = True,
print_msgs: bool = True,
fill_page_content: bool = False,
screen: int | None = None,
**kwargs,
) Any | None[source]
streamlitrunner.run(**kwargs) Any | None

Run the script file as a streamlit app and exits.

Executes the command streamlit run <script.py> before exit the program.

The parameters of this function have preference over the runtime config variable streamlitrunner.rc

Parameters

  • func (Callable[..., Any] | None, optional): Defaults to None.

    A function to run.

  • funcargs (Sequence[Any] | None, optional): Defaults to None.

    Positional arguments passed to function func.

  • funckwargs (dict[str, Any] | None, optional): Defaults to None.

    Keyword arguments passed to function func.

  • title (str, optional): Defaults to "Streamlit runner app".

    The title of the new window.

  • maximized (bool, optional): Defaults to True.

    Whether or not to start the window maximized.

  • open_as_app (bool, optional): Defaults to True.

    Whether to open the browser with webview launching the url in “application mode” in its own native window (separate window). If True, the option STREAMLIT_SERVER_HEADLESS is set to True.

  • print_msgs (bool, optional): Defaults to True.

    Whether to print the command executed by this function and other messages.

  • fill_page_content (bool, optional): Defaults to False.

    Whether to fill the web page removing empty spaces.

  • screen (int | None, optional): Defaults to None.

    The screen number to display the window on, if open_as_app=True.

  • **kwargs: Additional keyword arguments passed as options to the streamlit run

    command. These keyword arguments have the same names as the environment variables, but passed with lower case and without the prefix streamlit_. Use streamlit run --help to get a list.

    Some values are predefined, if not given. Namely:

    • client_toolbar_mode (STREAMLIT_CLIENT_TOOLBAR_MODE) = "minimal"

    • server_headless (STREAMLIT_SERVER_HEADLESS): True if open_as_app=True

    • server_run_on_save (STREAMLIT_SERVER_RUN_ON_SAVE) = True

    • server_port (STREAMLIT_SERVER_PORT) = 8501

    • theme_base (STREAMLIT_THEME_BASE) = "light"

Returns

Any | None:

If func is not None, return its result. Otherwise, returns None.