Untitled

mail@pastecode.io avatar
unknown
python
5 days ago
2.8 kB
1
Indexable
Never
import streamlit as st
from lesson_presenter import LessonPresenter, load_content, create_editor_screen

def create_home_page(content):
    st.title("Home Page")
    st.write("Welcome to the Interactive Lesson Content Editor!")
    
    if st.button("Create New Lesson Content"):
        st.session_state.current_page = "editor"
        st.session_state.content_generated = False
        st.session_state.json_content = {"subject": "", "lessons": []}
        st.rerun()
    
    # Display saved lesson contents
    for subject in content.get("subjects", []):
        subject_name = subject.get("subject", "Unknown")
        col1, col2 = st.columns(2)
        with col1:
            if st.button(f"Edit {subject_name}"):
                st.session_state.json_content = content
                st.session_state.content_generated = True
                st.session_state.current_page = "editor"
                st.session_state.selected_subject = subject_name
                st.rerun()
        with col2:
            if st.button(f"Edit Slides for {subject_name}"):
                st.session_state.current_page = "slides_editor"
                st.session_state.selected_subject = subject_name
                st.rerun()

def main():
    content = load_content()
    presenter = LessonPresenter(content)

    if 'current_page' not in st.session_state:
        st.session_state.current_page = "home"

    if st.session_state.current_page == "home":
        create_home_page(content)
    elif st.session_state.current_page == "editor":
        create_editor_screen(presenter)
    elif st.session_state.current_page == "slides_editor":
        presenter.set_subject_content(st.session_state.selected_subject)
        create_editor_screen(presenter)

if __name__ == "__main__":
    main()









import os
import json
import streamlit as st
import reveal_slides as rs

# ... [Keep all the existing classes: SlideComponent and LessonPresenter] ...

def load_content():
    # ... [Keep the existing load_content function] ...

def create_editor_screen(presenter: LessonPresenter):
    st.title("Lesson Presentation System")

    # Add a "Back to Home" button
    if st.button("Back to Home"):
        st.session_state.current_page = "home"
        st.rerun()

    subjects = [s["subject"] for s in presenter.content["subjects"]]
    selected_subject = st.sidebar.selectbox("Select Subject", subjects)
    presenter.set_subject_content(selected_subject)

    # ... [Keep the rest of the create_editor_screen function] ...

    slides_component = presenter.create_slide_component(presenter.json_to_slides(), config, initial_state={})
    slides_component.render()

# ... [Keep any other necessary functions] ...
Leave a Comment