streamlitrunner 0.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ docs/sphinx/build/
2
+ **/__pycache__/
@@ -0,0 +1 @@
1
+ 3.10
@@ -0,0 +1,37 @@
1
+ # Read the Docs configuration file for Sphinx projects
2
+ # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
3
+
4
+ # Required
5
+ version: 2
6
+
7
+ # Set the OS, Python version and other tools you might need
8
+ build:
9
+ os: ubuntu-24.04
10
+ tools:
11
+ python: "3.10"
12
+ # You can also specify other tool versions:
13
+ # nodejs: "20"
14
+ # rust: "1.70"
15
+ # golang: "1.20"
16
+ jobs:
17
+ pre_create_environment:
18
+ - asdf plugin add uv
19
+ - asdf install uv latest
20
+ - asdf global uv latest
21
+ create_environment:
22
+ - uv venv "${READTHEDOCS_VIRTUALENV_PATH}"
23
+ install:
24
+ - UV_PROJECT_ENVIRONMENT="${READTHEDOCS_VIRTUALENV_PATH}" uv sync --frozen --group docs
25
+
26
+ # Build documentation in the "docs/" directory with Sphinx
27
+ sphinx:
28
+ configuration: docs/sphinx/source/conf.py
29
+ # You can configure Sphinx to use a different builder, for instance use the dirhtml builder for simpler URLs
30
+ # builder: "dirhtml"
31
+ # Fail on all warnings to avoid broken references
32
+ # fail_on_warning: true
33
+
34
+ # Optionally build your docs in additional formats such as PDF and ePub
35
+ # formats:
36
+ # - pdf
37
+ # - epub
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Diogo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,52 @@
1
+ Metadata-Version: 2.4
2
+ Name: streamlitrunner
3
+ Version: 0.0.0
4
+ Summary: A module to run streamlit apps as local apps
5
+ Project-URL: Documentation, https://github.com/diogo-rossi/streamlitrunner
6
+ Project-URL: Issues, https://github.com/diogo-rossi/streamlitrunner/issues
7
+ Project-URL: Source, https://github.com/diogo-rossi/streamlitrunner
8
+ Author-email: Diogo Rossi <rossi.diogo@gmail.com>
9
+ License-File: LICENSE.txt
10
+ Classifier: Programming Language :: Python :: 3.10
11
+ Classifier: Programming Language :: Python :: Implementation :: CPython
12
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
13
+ Requires-Python: >=3.10
14
+ Requires-Dist: pywebview>=6.1
15
+ Requires-Dist: streamlit>=1.52.2
16
+ Description-Content-Type: text/markdown
17
+
18
+ # Streamlit Runner
19
+
20
+ ![](./docs/streamlitrunner.png)
21
+
22
+ A simple way to run Streamlit app as a desktop app
23
+
24
+ ## Installation
25
+
26
+ ```shell
27
+ pip install streamlitrunner
28
+ ```
29
+
30
+ ## Usage
31
+
32
+ Import `streamlitrunner` and call `run()`
33
+
34
+ ```python
35
+ # my_app.py
36
+ import streamlitrunner as sr
37
+ import streamlit as st
38
+
39
+ st.title("Hello World!")
40
+ st.write("This is a simple text example.")
41
+
42
+ if __name__ == '__main__':
43
+ sr.run()
44
+ ```
45
+
46
+ Now you can only call `python my_app.py` and it will work as a desktop app!
47
+
48
+ ![](docs/streamlitrunner-example.png)
49
+
50
+ ## Documentation:
51
+
52
+ [https://streamlitrunner.readthedocs.io/en/latest/](https://streamlitrunner.readthedocs.io/en/latest/)
@@ -0,0 +1,35 @@
1
+ # Streamlit Runner
2
+
3
+ ![](./docs/streamlitrunner.png)
4
+
5
+ A simple way to run Streamlit app as a desktop app
6
+
7
+ ## Installation
8
+
9
+ ```shell
10
+ pip install streamlitrunner
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ Import `streamlitrunner` and call `run()`
16
+
17
+ ```python
18
+ # my_app.py
19
+ import streamlitrunner as sr
20
+ import streamlit as st
21
+
22
+ st.title("Hello World!")
23
+ st.write("This is a simple text example.")
24
+
25
+ if __name__ == '__main__':
26
+ sr.run()
27
+ ```
28
+
29
+ Now you can only call `python my_app.py` and it will work as a desktop app!
30
+
31
+ ![](docs/streamlitrunner-example.png)
32
+
33
+ ## Documentation:
34
+
35
+ [https://streamlitrunner.readthedocs.io/en/latest/](https://streamlitrunner.readthedocs.io/en/latest/)
@@ -0,0 +1,2 @@
1
+ [.ShellClassInfo]
2
+ IconResource=C:\Users\Diogo\0\Repos\MyIcons\icons\streamlitrunner.ico,0
@@ -0,0 +1,20 @@
1
+ # Minimal makefile for Sphinx documentation
2
+ #
3
+
4
+ # You can set these variables from the command line, and also
5
+ # from the environment for the first two.
6
+ SPHINXOPTS ?=
7
+ SPHINXBUILD ?= sphinx-build
8
+ SOURCEDIR = source
9
+ BUILDDIR = build
10
+
11
+ # Put it first so that "make" without argument is like "make help".
12
+ help:
13
+ @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14
+
15
+ .PHONY: help Makefile
16
+
17
+ # Catch-all target: route all unknown targets to Sphinx using the new
18
+ # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19
+ %: Makefile
20
+ @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@@ -0,0 +1,35 @@
1
+ @ECHO OFF
2
+
3
+ pushd %~dp0
4
+
5
+ REM Command file for Sphinx documentation
6
+
7
+ if "%SPHINXBUILD%" == "" (
8
+ set SPHINXBUILD=sphinx-build
9
+ )
10
+ set SOURCEDIR=source
11
+ set BUILDDIR=build
12
+
13
+ %SPHINXBUILD% >NUL 2>NUL
14
+ if errorlevel 9009 (
15
+ echo.
16
+ echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17
+ echo.installed, then set the SPHINXBUILD environment variable to point
18
+ echo.to the full path of the 'sphinx-build' executable. Alternatively you
19
+ echo.may add the Sphinx directory to PATH.
20
+ echo.
21
+ echo.If you don't have Sphinx installed, grab it from
22
+ echo.https://www.sphinx-doc.org/
23
+ exit /b 1
24
+ )
25
+
26
+ if "%1" == "" goto help
27
+
28
+ %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29
+ goto end
30
+
31
+ :help
32
+ %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33
+
34
+ :end
35
+ popd
@@ -0,0 +1,5 @@
1
+ # API reference
2
+
3
+ ```{eval-rst}
4
+ .. autofunction:: streamlitrunner.run
5
+ ```
@@ -0,0 +1,4 @@
1
+ .sidebar-logo img {
2
+ height: 200px;
3
+ width: 200px;
4
+ }
@@ -0,0 +1,76 @@
1
+ # Configuration file for the Sphinx documentation builder.
2
+ #
3
+ # For the full list of built-in configuration values, see the documentation:
4
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html
5
+
6
+ # -- Project information -----------------------------------------------------
7
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
8
+
9
+ from datetime import datetime
10
+
11
+ thisyear = str(datetime.now().year)
12
+
13
+ project = "streamlitrunner"
14
+ copyright = f"{thisyear}, Diogo Rossi"
15
+ author = "Diogo Rossi"
16
+
17
+ import os
18
+ import sys
19
+
20
+ sys.path.insert(0, os.path.abspath("../../src/"))
21
+ import streamlitrunner
22
+
23
+ # -- General configuration ---------------------------------------------------
24
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
25
+
26
+ extensions = [
27
+ "sphinx.ext.autodoc",
28
+ "sphinx.ext.napoleon",
29
+ "sphinx.ext.viewcode",
30
+ "myst_parser",
31
+ "sphinx_copybutton",
32
+ "sphinx.ext.doctest",
33
+ "sphinx.ext.intersphinx",
34
+ "sphinx.ext.extlinks",
35
+ "sphinxnotes.comboroles",
36
+ ]
37
+
38
+ templates_path = ["_templates"]
39
+ exclude_patterns = []
40
+
41
+ maximum_signature_line_length = 70
42
+
43
+ # Napoleon settings
44
+ napoleon_google_docstring = True
45
+ napoleon_numpy_docstring = False
46
+
47
+ # Copy button settings
48
+ copybutton_exclude = ".linenos, .gp, .go"
49
+ copybutton_prompt_text = ">>> "
50
+
51
+ # Inter-sphinx settings
52
+ intersphinx_mapping = {"python": ("https://docs.python.org/3", None)}
53
+
54
+ # Ext-links settings
55
+ extlinks = {
56
+ "original": ("https://docs.python.org/3/library/argparse.html#%s", "%s"),
57
+ "argument": ("2_available_functions.html#%s", "%s"),
58
+ }
59
+
60
+ # Combo-roles settings
61
+ comboroles_roles = {
62
+ "original_link": ["literal", "original"],
63
+ "argument_link": ["literal", "argument"],
64
+ }
65
+
66
+ # -- Options for HTML output -------------------------------------------------
67
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
68
+
69
+ html_theme = "furo"
70
+ html_title = '<p style="text-align: center"><b>streamlitrunner</b></p>'
71
+ html_static_path = ["_static"]
72
+
73
+ html_css_files = ["css/custom.css"]
74
+ html_logo = "../../streamlitrunner.png"
75
+
76
+ default_role = "code"
@@ -0,0 +1,43 @@
1
+ # Streamlit-Runner
2
+
3
+ A simple way to run Streamlit app as a desktop app
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install streamlitrunner
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ Import `streamlitrunner` and call `run()`
14
+
15
+ ```python
16
+ # my_app.py
17
+ import streamlitrunner as sr
18
+ import streamlit as st
19
+
20
+ st.title("Hello World!")
21
+ st.write("This is a simple text example.")
22
+
23
+ if __name__ == '__main__':
24
+ sr.run()
25
+ ```
26
+
27
+ Now you can only call `python my_app.py` and it will work as a desktop app!
28
+
29
+ ![](../../streamlitrunner-example.png)
30
+
31
+ ## Links
32
+
33
+ ```{toctree}
34
+ :maxdepth: 1
35
+ API_reference
36
+ ```
37
+
38
+ - GitHub repository:
39
+ [https://github.com/diogo-rossi/streamlitrunner](https://github.com/diogo-rossi/streamlitrunner)
40
+ - PyPI:
41
+ [https://pypi.org/project/streamlitrunner/](https://pypi.org/project/streamlitrunner/)
42
+ - Documentation:
43
+ [https://streamlitrunner.readthedocs.io/en/latest/](https://streamlitrunner.readthedocs.io/en/latest/)
@@ -0,0 +1,48 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "streamlitrunner"
7
+ version = "0.0.0"
8
+ description = "A module to run streamlit apps as local apps"
9
+ readme = "README.md"
10
+ authors = [
11
+ { name = "Diogo Rossi", email = "rossi.diogo@gmail.com" },
12
+ ]
13
+ requires-python = ">=3.10"
14
+ dependencies = [
15
+ "pywebview>=6.1",
16
+ "streamlit>=1.52.2",
17
+ ]
18
+ classifiers = [
19
+ "Programming Language :: Python :: 3.10",
20
+ "Programming Language :: Python :: Implementation :: CPython",
21
+ "Programming Language :: Python :: Implementation :: PyPy",
22
+ ]
23
+
24
+ [project.urls]
25
+ Documentation = "https://github.com/diogo-rossi/streamlitrunner"
26
+ Issues = "https://github.com/diogo-rossi/streamlitrunner/issues"
27
+ Source = "https://github.com/diogo-rossi/streamlitrunner"
28
+
29
+ [dependency-groups]
30
+ docs = [
31
+ "sphinx-copybutton>=0.5.2",
32
+ "sphinx>=8.1.3",
33
+ "myst-parser>=4.0.1",
34
+ "furo>=2025.12.19",
35
+ "sphinxnotes-comboroles>=1.0",
36
+ ]
37
+ dev = [
38
+ "pytest>=9.0.2",
39
+ "taskipy>=1.14.1",
40
+ ]
41
+
42
+ [tool.pytest.ini_options]
43
+ addopts = "-rx -vv -s --tb=short"
44
+
45
+ [tool.taskipy.tasks]
46
+ docs = { cmd = "make html", cwd = "./docs/sphinx", help = "Make docs with sphinx" }
47
+ open = { cmd = "index.html", cwd = "./docs/sphinx/build/html", help = "Open sphinx docs" }
48
+ test = { cmd = "pytest", cwd = "./tests", help = "Test with pytest" }
@@ -0,0 +1 @@
1
+ from .streamlitrunner import *
@@ -0,0 +1,214 @@
1
+ import os
2
+ import sys
3
+ from pathlib import Path
4
+ from typing import Literal, TypedDict, overload
5
+ from threading import Thread
6
+
7
+ import webview
8
+ from streamlit import session_state
9
+ from streamlit.runtime.scriptrunner import get_script_run_ctx
10
+
11
+
12
+ class SessionState:
13
+ def __contains__(self, name: str) -> bool:
14
+ return hasattr(self, name)
15
+
16
+
17
+ gettrace = getattr(sys, "gettrace", None)
18
+ debugging = gettrace is not None and gettrace()
19
+ interactively_debugging = sys.flags.interactive or sys.flags.quiet or debugging
20
+ inside_streamlit_app = get_script_run_ctx()
21
+
22
+ session = SessionState()
23
+ if inside_streamlit_app:
24
+ session = session_state
25
+
26
+
27
+ class RuntimeConfig(TypedDict, total=False):
28
+ CLOSE_OPENED_WINDOW: bool
29
+ OPEN_AS_APP: bool
30
+ BROWSER: Literal["chrome", "msedge"]
31
+ PRINT_COMMAND: bool
32
+ STREAMLIT_GLOBAL_DISABLE_WATCHDOG_WARNING: bool
33
+ STREAMLIT_GLOBAL_DISABLE_WIDGET_STATE_DUPLICATION_WARNING: bool
34
+ STREAMLIT_GLOBAL_SHOW_WARNING_ON_DIRECT_EXECUTION: bool
35
+ STREAMLIT_GLOBAL_DEVELOPMENT_MODE: bool
36
+ STREAMLIT_GLOBAL_LOG_LEVEL: Literal["error", "warning", "info", "debug"]
37
+ STREAMLIT_GLOBAL_UNIT_TEST: bool
38
+ STREAMLIT_GLOBAL_APP_TEST: bool
39
+ STREAMLIT_GLOBAL_SUPPRESS_DEPRECATION_WARNINGS: bool
40
+ STREAMLIT_GLOBAL_MIN_CACHED_MESSAGE_SIZE: float
41
+ STREAMLIT_GLOBAL_MAX_CACHED_MESSAGE_AGE: int
42
+ STREAMLIT_GLOBAL_STORE_CACHED_FORWARD_MESSAGES_IN_MEMORY: bool
43
+ STREAMLIT_GLOBAL_DATA_FRAME_SERIALIZATION: Literal["legacy", "arrow"]
44
+ STREAMLIT_LOGGER_LEVEL: Literal["error", "warning", "info", "debug"]
45
+ STREAMLIT_LOGGER_MESSAGE_FORMAT: str
46
+ STREAMLIT_LOGGER_ENABLE_RICH: bool
47
+ STREAMLIT_CLIENT_CACHING: bool
48
+ STREAMLIT_CLIENT_DISPLAY_ENABLED: bool
49
+ STREAMLIT_CLIENT_SHOW_ERROR_DETAILS: bool
50
+ STREAMLIT_CLIENT_TOOLBAR_MODE: Literal["auto", "developer", "viewer", "minimal"]
51
+ STREAMLIT_CLIENT_SHOW_SIDEBAR_NAVIGATION: bool
52
+ STREAMLIT_RUNNER_MAGIC_ENABLED: bool
53
+ STREAMLIT_RUNNER_INSTALL_TRACER: bool
54
+ STREAMLIT_RUNNER_FIX_MATPLOTLIB: bool
55
+ STREAMLIT_RUNNER_POST_SCRIPT_GC: bool
56
+ STREAMLIT_RUNNER_FAST_RERUNS: bool
57
+ STREAMLIT_RUNNER_ENFORCE_SERIALIZABLE_SESSION_STATE: bool
58
+ STREAMLIT_RUNNER_ENUM_COERCION: Literal["off", "nameOnly", "nameAndValue"]
59
+ STREAMLIT_SERVER_FOLDER_WATCH_BLACKLIST: str
60
+ STREAMLIT_SERVER_FILE_WATCHER_TYPE: Literal["auto", "watchdog", "poll", "none"]
61
+ STREAMLIT_SERVER_HEADLESS: bool
62
+ STREAMLIT_SERVER_RUN_ON_SAVE: bool
63
+ STREAMLIT_SERVER_ALLOW_RUN_ON_SAVE: bool
64
+ STREAMLIT_SERVER_ADDRESS: str
65
+ STREAMLIT_SERVER_PORT: int
66
+ STREAMLIT_SERVER_SCRIPT_HEALTH_CHECK_ENABLED: bool
67
+ STREAMLIT_SERVER_BASE_URL_PATH: str
68
+ STREAMLIT_SERVER_ENABLE_CORS: bool
69
+ STREAMLIT_SERVER_ENABLE_XSRF_PROTECTION: bool
70
+ STREAMLIT_SERVER_MAX_UPLOAD_SIZE: int
71
+ STREAMLIT_SERVER_MAX_MESSAGE_SIZE: int
72
+ STREAMLIT_SERVER_ENABLE_ARROW_TRUNCATION: bool
73
+ STREAMLIT_SERVER_ENABLE_WEBSOCKET_COMPRESSION: bool
74
+ STREAMLIT_SERVER_ENABLE_STATIC_SERVING: bool
75
+ STREAMLIT_BROWSER_SERVER_ADDRESS: str
76
+ STREAMLIT_BROWSER_GATHER_USAGE_STATS: bool
77
+ STREAMLIT_BROWSER_SERVER_PORT: int
78
+ STREAMLIT_SERVER_SSL_CERT_FILE: str
79
+ STREAMLIT_SERVER_SSL_KEY_FILE: str
80
+ STREAMLIT_UI_HIDE_TOP_BAR: bool
81
+ STREAMLIT_UI_HIDE_SIDEBAR_NAV: bool
82
+ STREAMLIT_MAGIC_DISPLAY_ROOT_DOC_STRING: bool
83
+ STREAMLIT_MAGIC_DISPLAY_LAST_EXPR_IF_NO_SEMICOLON: bool
84
+ STREAMLIT_DEPRECATION_SHOWFILE_UPLOADER_ENCODING: bool
85
+ STREAMLIT_DEPRECATION_SHOW_IMAGE_FORMAT: bool
86
+ STREAMLIT_DEPRECATION_SHOW_PYPLOT_GLOBAL_USE: bool
87
+ STREAMLIT_THEME_BASE: Literal["dark", "light"]
88
+ STREAMLIT_THEME_PRIMARY_COLOR: str
89
+ STREAMLIT_THEME_BACKGROUND_COLOR: str
90
+ STREAMLIT_THEME_SECONDARY_BACKGROUND_COLOR: str
91
+ STREAMLIT_THEME_TEXT_COLOR: str
92
+ STREAMLIT_THEME_FONT: Literal["sans serif", "serif", "monospace"]
93
+
94
+
95
+ rc: RuntimeConfig = {
96
+ "OPEN_AS_APP": True,
97
+ "BROWSER": "msedge",
98
+ "CLOSE_OPENED_WINDOW": True,
99
+ "PRINT_COMMAND": True,
100
+ "STREAMLIT_CLIENT_TOOLBAR_MODE": "minimal",
101
+ "STREAMLIT_SERVER_RUN_ON_SAVE": True,
102
+ "STREAMLIT_SERVER_PORT": 8501,
103
+ "STREAMLIT_THEME_BASE": "light",
104
+ }
105
+
106
+ for key in rc:
107
+ if key.startswith("STREAMLIT_") and key in os.environ:
108
+ rc[key] = os.environ[key]
109
+
110
+
111
+ @overload
112
+ def run(
113
+ *,
114
+ title: str = "Streamlit runner app",
115
+ maximized: bool = True,
116
+ open_as_app: bool = True,
117
+ print_command: bool = True,
118
+ **kwargs,
119
+ ): ...
120
+
121
+
122
+ @overload
123
+ def run(**kwargs): ...
124
+
125
+
126
+ def run(
127
+ **kwargs,
128
+ ):
129
+ """Run the script file as a streamlit app and exits.
130
+
131
+ Executes the command `streamlit run <script.py>` before exit the program.
132
+
133
+ The parameters of this function have preference over the runtime config variable `streamlitrunner.rc`
134
+
135
+ Parameters
136
+ ----------
137
+ - `title` (`str`, optional): Defaults to `"Streamlit runner app"`.
138
+ The title of the new window.
139
+
140
+ - `maximized` (`bool`, optional): Defaults to `True`.
141
+ Whether or not to start the window maximized.
142
+
143
+ - `open_as_app` (`bool`, optional): Defaults to `True`.
144
+ Whether to open the chromium based browser launching the url in "application mode" with `--app=` argument (separate window).
145
+ If `True`, the option `STREAMLIT_SERVER_HEADLESS` is set to `True`.
146
+
147
+ - `print_command` (`bool`, optional): Defaults to `True`.
148
+ Whether to print the command executed by this function.
149
+
150
+ - `**kwargs`: Additional keyword arguments passed as options to the `streamlit run` command.
151
+ These keyword arguments have the same names as the environment variables, but passed with
152
+ lower case and without the prefix `streamlit_`. Use `streamlit run --help` to get a list.
153
+
154
+ Some values are predefined, if not given. Namely:
155
+
156
+ + `client_toolbar_mode` (`STREAMLIT_CLIENT_TOOLBAR_MODE`) = `"minimal"`
157
+
158
+ + `server_headless` (`STREAMLIT_SERVER_HEADLESS`): `True` if `open_as_app=True`
159
+
160
+ + `server_run_on_save` (`STREAMLIT_SERVER_RUN_ON_SAVE`) = `True`
161
+
162
+ + `server_port` (`STREAMLIT_SERVER_PORT`) = `8501`
163
+
164
+ + `theme_base` (`STREAMLIT_THEME_BASE`) = `"light"`
165
+ """
166
+ if not inside_streamlit_app and not interactively_debugging:
167
+
168
+ if "STREAMLIT_SERVER_HEADLESS" not in rc:
169
+ if "STREAMLIT_SERVER_HEADLESS" in os.environ:
170
+ rc["STREAMLIT_SERVER_HEADLESS"] = bool(os.environ["STREAMLIT_SERVER_HEADLESS"])
171
+ else:
172
+ if kwargs.get("open_as_app", True):
173
+ rc["STREAMLIT_SERVER_HEADLESS"] = True
174
+ else:
175
+ rc["STREAMLIT_SERVER_HEADLESS"] = False
176
+
177
+ spec_args = ["open_as_app", "print_command", "title", "maximized"]
178
+
179
+ for key in kwargs:
180
+ rc[(key if key in spec_args else f"streamlit_{key}").upper()] = kwargs[key]
181
+
182
+ for option in rc:
183
+ if option.startswith("STREAMLIT_"):
184
+ os.environ[option] = str(rc[option])
185
+
186
+ server_headless: bool = rc["STREAMLIT_SERVER_HEADLESS"]
187
+ print_command: bool = rc.get("PRINT_COMMAND", True)
188
+ open_as_app: bool = rc.get("OPEN_AS_APP", True)
189
+ server_port: int = rc.get("STREAMLIT_SERVER_PORT", 8501)
190
+ maximized: bool = rc.get("MAXIMIZED", True)
191
+ title: str = rc.get("TITLE", "Streamlit runner app")
192
+
193
+ def run_streamlit():
194
+ streamlit = Path(sys.executable).resolve().parent / "streamlit.exe"
195
+ if not streamlit.exists():
196
+ streamlit = "streamlit"
197
+ command = f'{streamlit} run --server.headless {server_headless} --server.port {server_port} {sys.argv[0]} -- {" ".join(sys.argv[1:])}'
198
+ if print_command:
199
+ print(command)
200
+ os.system(command)
201
+
202
+ try:
203
+ if open_as_app:
204
+ thread = Thread(target=run_streamlit)
205
+ thread.daemon = True
206
+ thread.start()
207
+ webview.create_window(title, f"http://localhost:{server_port}/", maximized=maximized)
208
+ webview.start()
209
+ else:
210
+ run_streamlit()
211
+
212
+ except KeyboardInterrupt:
213
+ sys.exit()
214
+ sys.exit()