Python Leiden (NL) meetup: building apps with streamlit - Daniël Kentrop

Tags: python, pun

(One of my summaries of the Leiden (NL) Python meetup).

Daniël is a civil engineer turned software developer. He works for a company involved in improving the 17000 km of dikes in the Netherlands. He liked programming, but interfacing with his colleagues was a bit problematic. Jupyter notebooks without a venv? Interfaces with QT (which explode in size)? PyInstaller? In the end, he often opted for data in an excel sheet and then running a python script…

He now likes to use streamlit, a Python library for creating simple web apps, prototyping, visualisation. It has lots of build-in elements and widgets. Data entry, all sorts of (plotly) charts, sliders, selectboxes, pop-ups, basically everything you need.

You can add custom components with html/css/js.

How does it work? It is basically a script. The whole page is loaded every time and re-run. A widget interaction means a re-run. Pressing a button means a re-run. There is state you can store on the server per session. He showed a demo demonstrating the problems caused by the constant re-running (and losing of state) and how to solve it with the session state.

He then showed a bigger streamlit demo. On a map, you could draw an area and select water level measurement stations and then show water levels of the last month. Nice.

An upcoming change to streamlit: they’re going to move from the Tornado web runner to Starlette, which also means ASGI support.