Skip to main content
In this tutorial, we will build a Student Progress Report Application to practice structuring and laying out user interfaces in Streamlit. We will cover layout elements step-by-step:
  1. Containers, Borders, and Dividers (st.container, st.divider)
  2. Columns (st.columns)
  3. Tabs (st.tabs)
  4. Multipage Apps (pages/ directory)

πŸ“„ Sample Dataset (grades.csv)

Before starting the exercises, create a file named grades.csv in your project folder with the following Indian school grades dataset:

πŸ› οΈ Step 1: Layout, Borders, & Dividers

We will organize the student info and AI feedback inside distinct visual boxes (containers with borders) separated by clean horizontal lines. Create a file named exercise_1_basic_layout.py and add the following:
Run the script to see the borders and dividers:

πŸ› οΈ Step 2: Arranging Content in Columns

Next, let’s display the student profile on the left and the academic grades side-by-side on the right using st.columns. Create a file named exercise_2_columns.py and add the following:
Run the script:

πŸ› οΈ Step 3: Structuring Views in Tabs

When you have a lot of content, columns can get cramped. We can use st.tabs to create clean, switchable views for Overview, Grades, and AI Insights. Create a file named exercise_3_tabs.py and add the following:
Run the script:

πŸ› οΈ Step 4: Structuring a Multipage App

Finally, to create a fully production-ready structure, let’s separate these features into multiple pages using Streamlit’s native pages/ directory layout.

File Structure

Set up the files exactly as shown below:

1. Main Page (app.py)

2. Metrics Page (pages/1_πŸ“Š_Detailed_Metrics.py)

3. AI Feedback Page (pages/2_πŸ€–_AI_Feedback.py)

Run the multipage app from the root directory:

πŸ› οΈ Step 5: Capstone Exercise β€” Dynamic CSV Report Generator

❓ Question / Goal

Build an application where a teacher can enter student details (Name, Roll Number, Branch) and upload a CSV file containing marks in various subjects. The application should dynamically parse the uploaded file, display the student details in a clean layout, show the detailed scorecard, and render a performance summary (average score, highest marks, etc.) with custom remarks.

πŸ“‹ Implementation Plan

  1. Define Layout: Use st.columns([1, 2]) to split the page into an Input Form (left column, width 1) and the Generated Report (right column, width 2).
  2. Collect Inputs: Place student metadata fields inside a st.form block on the left column.
  3. Handle CSV Upload: Include a st.file_uploader inside the form to accept .csv files.
  4. Parse & Verify Data: On submit, parse the CSV using pandas and check that the required columns (Subject, Marks, Grade) exist.
  5. Render Report Card:
    • Render student details inside a bordered container.
    • Display the subject grades using st.dataframe.
    • Calculate summary stats (average, max marks) and display them in columns using st.metric.
    • Output rule-based feedback remarks in a color-coded alert (st.success, st.warning).

πŸ“¦ Key Components Used

  • st.form & st.form_submit_button: Groups input elements together to prevent page reruns on every keystroke.
  • st.file_uploader: Reads user-supplied CSV files into memory.
  • st.columns: Organizes the sidebar layout as well as the inner metrics side-by-side.
  • st.container(border=True): Visually isolates the Profile, Grades, and Summary sections.
  • st.dataframe: Formats the parsed tabular marks data.
  • st.metric: Displays the computed GPA, average score, and total count.

πŸ“ Code Implementation (exercise_4_csv_report.py)

To run this exercise: