Hacker News new | ask | show | jobs
by JPKab 1913 days ago
How is this different from streamlit?

Curious.

2 comments

Streamlit uses a responsive way to get input and doesn't rely on callbacks at all. Every time a user interacts with a widget, your script is re-executed and the output value of that widget is set to the new value during that run. It's amazing but also a little hard to understand.

In contrast, the way of writing PyWebIO app is more like writing a terminal program, except that the terminal here becomes a browser. The output functions will output content to user in real time, and the input functions will block until the user submit the input form.

So, PyWebIO doesn't re-execute the whole script like Streamlit does? I use streamlit, and that's one of its pain points. If the script is complicated, re-execution becomes slow.

Also does PyWebIO support defining inputs based on other ones? For example, to have a hierarchy of dropdowns (select company --> based on that selection, select employee --> etc).

PyWebIO won't re-execute the whole script. In pywebio, if the code executes to the end, the user session will also be closed. You can use `while` loop in your code to continuously receive user input in PyWebIO app.

PyWebIO now support defining inputs based on other ones, but I haven't written this feature into the documentation. Until then, you can solve this problem by splitting inputs with dependencies into multiple forms. (you can use first form to get company and then use another form to get employee)

Excellent work, and thank you for sharing!

I see some immediate applications for this at my job. Much appreciation!

Not finding a reason to use this over Streamlit which is pretty polished and has good layout, pandas df support and other nice bells and whistles.

Edit: actually did. Running apps from a directory was something I was looking for and there was only a third party effort for Streamlit for this - https://pywebio.readthedocs.io/en/latest/platform.html#direc...

PyWebIO is more lightweight and supports coroutine and web framework integration.

Although PyWebIO is indeed a bit crude, the usage scenarios of PyWebIO and streamlit don't exactly overlap.

What do you mean by "running apps from a directory?" Do you mean having multiple streamlit apps in a folder and being able to access all of them using a single server?