liveBook · Manning

Streamlit

As explained in Python How-To

Streamlit is an open-source Python library for building interactive data applications and web interfaces from Python scripts.

Need a browser-based interface for a Python task manager? Streamlit turns a Python script into a web app and provides widgets such as buttons and text inputs. It lays out those elements for you, so you can focus on the app’s behavior rather than its page layout. section 14.2.1 section 14.4.1

Install Streamlit in an activated virtual environment with `pip install streamlit==1.10.0`. To launch a script, run `streamlit run taskier_app.py` from its directory. The app opens in a tab in your default browser; use that tab to check changes while developing. section 14.1.3 section 14.4.9

The key execution detail is that a change to an input reruns the entire script from top to bottom. Keep information needed across those reruns in `st.session_state`, a key-value store for the active browser session. A task manager can retain its selected page, current task, and sorting and filtering choices there. section 14.4.1 section 14.4.3

Listing 14.9 Calling the functions to create the web app
if __name__ == "__main__":
    init_session()             #1
    setup_sidebar()
    if session[menu_key] == TaskierMenuOption.SHOW_TASKS.value:
        show_tasks()
    elif session[menu_key] == TaskierMenuOption.NEW_TASK.value:
        show_new_task_entry()
    elif session[menu_key] == TaskierMenuOption.SHOW_TASK_DETAIL.value:
        show_task_detail()
    else:
        st.write("No matching menu")

This entry point initializes session state, sets up the sidebar, then calls the function for the selected page. The branches make page navigation explicit in the script that Streamlit runs. section 14.4.3

Keep the app script focused on interface configuration: put imports first, then shared variables and functions grouped by purpose. Place a substantial data model in a separate file and import it. That makes the interface easier to read and leaves the model available for other kinds of app. section 14.4.8

How Python How-To covers it

How deep it goes
Explains installation, launching, widgets, script reruns, session tracking, and project organization, but defers a comprehensive widget tutorial.
Examples
Uses a task manager with a sidebar, task pages, stored sorting choices, and a `streamlit run` command.
What it assumes
Assumes Python scripting and introduces the essential Streamlit commands, widgets, and execution behavior needed for the app.
What you can do after
Apply Streamlit to build and run a browser-based task manager while retaining page and filter choices across script reruns.
How it connects
Connects Python scripts and virtual environments to web widgets, session state, command-line tools, and data-model separation.

Also explained in

Compare how 9 books explain Streamlit →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Python How-To. The section links point to the parts of the book it draws on.