beeware / beeware/toga

Add a streamlit backend for Positron

Open
#3,450 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
5.4k
Forks
827
Avg merge
15h 39m
Merged PRs (30d)
40

Description

### What is the problem or limitation you are having?

[Streamlit](https://streamlit.io/#install) is a popular GUI toolkit in the web visualisation space. It should be possible to wrap a Streamlit app in Positron.

### Describe the solution you'd like

A new Positron backend, adding an option for deploying a Streamlit app.

### Describe alternatives you've considered

Don't deploy Streamlit apps 😢

### Additional context

A bare bones working example:
```
from streamlit.web import bootstrap as streamlit

class StreamLitApp(toga.App):
def startup(self):
self.web_view = toga.WebView()
self.main_window = toga.MainWindow(title=self.formal_name)
self.main_window.content = self.web_view

async def on_running(self):
streamlit.load_config_options({
"server.fileWatcherType": "none",
"server.port": "8501",
})
server = streamlit.Server(str(Path(__file__).parent / "gui.py"), False)
await server.start()
self.web_view.url = "http://127.0.0.1:8501/"
self.main_window.show()
await server.stopped
```
where `gui.py` is the Streamlit app code; something like:
```
import streamlit as st

st.title("Hello, Streamlit!")
```
is a starting point for that file.

This sample code requires a little more work - the port should be auto-allocated and extracted from the server, rather than hard-coding `8501`; and the demo currently raises an warning about the Altair theme for some reason.

There may also be an opportunity to make the served app a little cleaner - I don't know if the external "chrome" of Streamlit can/should be removed as part of the serving process.

Contributor guide

Open the contributing guide

Research direction

Start by running the bare-bones example using streamlit.web.bootstrap, StreamLitApp.startup, StreamLitApp.on_running, and gui.py. Review how the Positron backend entry point should expose a Streamlit deployment option. Done means a Streamlit app can be launched without a hard-coded port, with the served app displayed in the web view; investigate the Altair warning and external chrome separately.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, streamlit
Domain
desktop, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.