Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,128 +1,3 @@
|
|
| 1 |
-
# import streamlit as st
|
| 2 |
-
# import pandas as pd
|
| 3 |
-
# from fpdf import FPDF
|
| 4 |
-
# import datetime
|
| 5 |
-
# import io
|
| 6 |
-
|
| 7 |
-
# # Initialize session state
|
| 8 |
-
# def init_session_state():
|
| 9 |
-
# if "study_data" not in st.session_state:
|
| 10 |
-
# st.session_state.study_data = pd.DataFrame(columns=["Subject", "Topic", "Goal", "Progress (%)"])
|
| 11 |
-
# if "calendar_data" not in st.session_state:
|
| 12 |
-
# st.session_state.calendar_data = pd.DataFrame({"Day": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"], "Planned Topic": ["" for _ in range(7)]})
|
| 13 |
-
|
| 14 |
-
# # PDF Generation
|
| 15 |
-
# def generate_pdf(df):
|
| 16 |
-
# pdf = FPDF()
|
| 17 |
-
# pdf.add_page()
|
| 18 |
-
# pdf.set_font("Arial", size=12)
|
| 19 |
-
# pdf.cell(200, 10, txt="Study Plan Report", ln=True, align='C')
|
| 20 |
-
# pdf.ln(10)
|
| 21 |
-
|
| 22 |
-
# for i, row in df.iterrows():
|
| 23 |
-
# pdf.multi_cell(0, 10, f"Subject: {row['Subject']}\nTopic: {row['Topic']}\nGoal: {row['Goal']}\nProgress: {row['Progress (%)']}%\n")
|
| 24 |
-
# pdf.ln(1)
|
| 25 |
-
|
| 26 |
-
# file_path = "study_report.pdf"
|
| 27 |
-
# pdf.output(file_path)
|
| 28 |
-
# return file_path
|
| 29 |
-
|
| 30 |
-
# def main():
|
| 31 |
-
# st.set_page_config(page_title="Study Planner", layout="wide")
|
| 32 |
-
# st.title("π Course Organizer & Study Planner")
|
| 33 |
-
|
| 34 |
-
# init_session_state()
|
| 35 |
-
|
| 36 |
-
# st.sidebar.markdown("---")
|
| 37 |
-
# st.sidebar.header("π Upload Your Study Plan")
|
| 38 |
-
# uploaded_plan = st.sidebar.file_uploader("Upload Study CSV", type=["csv"])
|
| 39 |
-
# uploaded_calendar = st.sidebar.file_uploader("Upload Calendar CSV", type=["csv"])
|
| 40 |
-
|
| 41 |
-
# # Handle uploads
|
| 42 |
-
# if uploaded_plan:
|
| 43 |
-
# st.session_state.study_data = pd.read_csv(uploaded_plan)
|
| 44 |
-
# if uploaded_calendar:
|
| 45 |
-
# st.session_state.calendar_data = pd.read_csv(uploaded_calendar)
|
| 46 |
-
|
| 47 |
-
# with st.sidebar:
|
| 48 |
-
# st.header("β Add Study Task")
|
| 49 |
-
# subject = st.text_input("Subject")
|
| 50 |
-
# topic = st.text_input("Topic")
|
| 51 |
-
# goal = st.text_area("Goal Description")
|
| 52 |
-
# progress = st.slider("Progress (%)", 0, 100, 0)
|
| 53 |
-
|
| 54 |
-
# if st.button("Add Task"):
|
| 55 |
-
# if subject and topic:
|
| 56 |
-
# new_row = {"Subject": subject, "Topic": topic, "Goal": goal, "Progress (%)": progress}
|
| 57 |
-
# st.session_state.study_data = pd.concat([
|
| 58 |
-
# st.session_state.study_data,
|
| 59 |
-
# pd.DataFrame([new_row])
|
| 60 |
-
# ], ignore_index=True)
|
| 61 |
-
# st.success("Task added!")
|
| 62 |
-
# else:
|
| 63 |
-
# st.error("Subject and Topic are required.")
|
| 64 |
-
|
| 65 |
-
# df = st.session_state.study_data
|
| 66 |
-
# calendar_df = st.session_state.calendar_data
|
| 67 |
-
|
| 68 |
-
# st.subheader("π― Study Summary by Subject")
|
| 69 |
-
# if not df.empty:
|
| 70 |
-
# subjects = df["Subject"].unique()
|
| 71 |
-
# cols = st.columns(len(subjects))
|
| 72 |
-
# colors = ["#fca311", "#a1c181", "#f28482", "#8ecae6", "#ffb703"]
|
| 73 |
-
|
| 74 |
-
# for i, subject in enumerate(subjects):
|
| 75 |
-
# sub_df = df[df["Subject"] == subject]
|
| 76 |
-
# avg_progress = int(sub_df["Progress (%)"].mean())
|
| 77 |
-
# with cols[i % len(cols)]:
|
| 78 |
-
# st.markdown(f"""
|
| 79 |
-
# <div style='padding: 1em; border-radius: 10px; background-color: {colors[i % len(colors)]}; color: black'>
|
| 80 |
-
# <h4>{subject}</h4>
|
| 81 |
-
# <p>Topics: {len(sub_df)}</p>
|
| 82 |
-
# <p>Avg. Progress: {avg_progress}%</p>
|
| 83 |
-
# </div>
|
| 84 |
-
# """, unsafe_allow_html=True)
|
| 85 |
-
|
| 86 |
-
# st.subheader("π
Weekly Study Calendar")
|
| 87 |
-
# days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
|
| 88 |
-
# calendar_data = []
|
| 89 |
-
# for day in days:
|
| 90 |
-
# default_topic = calendar_df.set_index("Day").get("Planned Topic", {}).get(day, "")
|
| 91 |
-
# topic = st.text_input(f"{day}", value=default_topic)
|
| 92 |
-
# calendar_data.append({"Day": day, "Planned Topic": topic})
|
| 93 |
-
|
| 94 |
-
# if st.button("Save Weekly Plan"):
|
| 95 |
-
# st.session_state.calendar_data = pd.DataFrame(calendar_data)
|
| 96 |
-
# st.success("Weekly calendar saved.")
|
| 97 |
-
|
| 98 |
-
# st.markdown("---")
|
| 99 |
-
# st.subheader("π All Study Tasks (Editable)")
|
| 100 |
-
# if not df.empty:
|
| 101 |
-
# edited_df = st.data_editor(df, num_rows="dynamic", use_container_width=True)
|
| 102 |
-
# st.session_state.study_data = edited_df
|
| 103 |
-
|
| 104 |
-
# st.markdown("---")
|
| 105 |
-
# st.subheader("π Progress Summary")
|
| 106 |
-
# summary = edited_df.groupby("Subject")["Progress (%)"].mean().reset_index()
|
| 107 |
-
# st.bar_chart(summary.set_index("Subject"))
|
| 108 |
-
|
| 109 |
-
# st.markdown("---")
|
| 110 |
-
# st.subheader("π€ Export Options")
|
| 111 |
-
|
| 112 |
-
# csv = df.to_csv(index=False).encode("utf-8")
|
| 113 |
-
# st.download_button("β¬οΈ Download CSV", data=csv, file_name="study_data.csv", mime="text/csv")
|
| 114 |
-
|
| 115 |
-
# if st.button("π Generate PDF Report"):
|
| 116 |
-
# file_path = generate_pdf(edited_df)
|
| 117 |
-
# with open(file_path, "rb") as f:
|
| 118 |
-
# st.download_button("π₯ Download PDF", f, file_name="study_plan_report.pdf")
|
| 119 |
-
# else:
|
| 120 |
-
# st.info("No tasks added yet.")
|
| 121 |
-
|
| 122 |
-
# if __name__ == "__main__":
|
| 123 |
-
# main()
|
| 124 |
-
|
| 125 |
-
|
| 126 |
import streamlit as st
|
| 127 |
import pandas as pd
|
| 128 |
from fpdf import FPDF
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
from fpdf import FPDF
|