Install and build your first lecture¶
Requirements¶
Python 3.10 or later. The visual components target modern browsers. Notebook canvas styling has been verified in JupyterLab. Hosted notebook platforms may sanitize CSS, so validate their output before teaching.
Install in the correct environment¶
python -m pip install "jupyter-lecture-studio[notebook,highlight]"
Inside a notebook, install into the current kernel:
%pip install "jupyter-lecture-studio[notebook,highlight]"
Restart the kernel after installation or upgrading. notebook installs IPython for display. highlight adds Pygments for languages such as Java, C++ and SQL. Python highlighting is built in.
For a script that only exports HTML:
python -m pip install jupyter-lecture-studio
Cell 1: create the lecture identity¶
from jupyter_lecture_studio import LectureDeck
deck = LectureDeck(
course="Database Fundamentals",
series="DATABASE SERIES",
lesson="01",
language="sql",
direction="ltr",
theme="gold",
)
Create one deck per lecture. Its brand controls the repeated labels, while its theme controls color, direction, motion and width.
Cell 2: introduce the lesson¶
deck.cover(
"Ask better questions of your data",
"Select only what you need.\nExplain why the result is correct.",
tags=["Understand", "Predict", "Try"],
sections=[
{"title": "The idea", "description": "Columns and rows"},
{"title": "The application", "description": "Write a SELECT query"},
],
hero_code="SELECT name FROM students;",
hero_result="A focused result",
hero_label="SQL LAB",
footer_label="DATABASE / FOUNDATIONS",
)
Cell 3: explain and check understanding¶
deck.slide(
"Select a column",
"A projection chooses the fields in the result.",
cards=[
{"title": "Concept", "explanation": "SELECT lists the requested columns."},
{"title": "Example", "code": "SELECT name FROM students;"},
],
activity={
"question": "Will the result contain the grade column?",
"answer": "No. Only name appears in the SELECT list.",
"label": "Predict first",
"reveal": "Show the explanation",
},
)
Add executable student examples in separate code cells. Displaying a code card never executes its text.
Scripts and repeated execution¶
Methods display and return None by default. In scripts, use show=False:
from jupyter_lecture_studio import LectureDeck
deck = LectureDeck(course="Offline lesson", direction="ltr", motion=False)
html = deck.slide("A useful idea", cards=[{"title": "Explain", "explanation": "Keep it focused."}], show=False)
deck.export("lesson.html")
Rerunning a slide appends another component and advances its number. Rerun the deck creation cell before rerunning all display cells, or call deck.clear() to start a fresh collection.
Existing notebooks¶
from lecture_studio import LectureDeck remains supported and refers to the same classes. Installing the new distribution does not require editing your existing imports. New lessons can use jupyter_lecture_studio consistently with the PyPI name.