-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
123 lines (108 loc) · 4.77 KB
/
Copy pathapp.py
File metadata and controls
123 lines (108 loc) · 4.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import streamlit as st
import pandas as pd
from datetime import datetime, timedelta
# Function to set the background image
def set_bg_image(image_url):
st.markdown(
f"""
<style>
.stApp {{
background-image: url("{image_url}");
background-size: cover;
background-position: center;
background-repeat: no-repeat;
height: 100vh;
color: #fff;
font-family: 'Arial', sans-serif;
}}
h1, h2, h3 {{
font-family: 'Courier New', Courier, monospace; /* Stylish Font */
}}
.stTextInput, .stTextArea, .stSelectbox, .stDateInput {{
background-color: rgba(255, 255, 255, 0.8);
border-radius: 10px; /* Rounded boxes */
padding: 10px;
font-size: 16px;
border: 2px solid #4CAF50; /* Green border */
}}
.stButton {{
background-color: #4CAF50; /* Green */
color: white;
padding: 10px 20px;
border-radius: 5px;
border: none;
cursor: pointer;
}}
.stButton:hover {{
background-color: #45a049; /* Darker green */
}}
</style>
""",
unsafe_allow_html=True
)
# App title
st.title("University Timetable and Task Manager")
# Set initial background image
default_bg = "https://www.w3schools.com/w3images/lights.jpg"
set_bg_image(default_bg)
# Background Image Selection
st.sidebar.header("Settings")
bg_image = st.sidebar.selectbox("Choose Background Image",
["https://www.w3schools.com/w3images/lights.jpg",
"https://www.w3schools.com/w3images/fjords.jpg",
"https://www.w3schools.com/w3images/nature.jpg",
"https://www.w3schools.com/w3images/mountains.jpg"])
set_bg_image(bg_image)
# Input number of classes
st.header("Enter Your Classes")
num_classes = st.number_input("Number of Classes:", min_value=1, max_value=10, value=1)
# Initialize a session state for storing classes
if 'classes' not in st.session_state:
st.session_state.classes = []
# Form for adding class details
for i in range(num_classes):
with st.form(key=f'class_form_{i}'):
class_name = st.text_input(f"Class Name {i + 1}")
topics = st.text_area(f"Topics for {class_name} (comma-separated)")
deadline = st.date_input(f"Assignment Deadline for {class_name}")
priority = st.selectbox(f"Priority for {class_name}", ["High", "Medium", "Low"])
# Submit button
submit_button = st.form_submit_button(label="Add Class")
# If user clicks the submit button
if submit_button:
if class_name and topics: # Ensure inputs are not empty
st.session_state.classes.append({
"Class Name": class_name,
"Topics": topics.split(','),
"Deadline": deadline,
"Priority": priority
})
st.success(f"Added: {class_name} with topics {topics}")
# Ask for assignments or quizzes
if st.session_state.classes:
st.header("Additional Tasks")
for cls in st.session_state.classes:
with st.expander(cls["Class Name"]):
has_assignment = st.radio(f"Is there an assignment or quiz for {cls['Class Name']}?",
["Yes", "No"], key=f'has_assignment_{cls["Class Name"]}')
if has_assignment == "Yes":
assignment_deadline = st.date_input(f"Assignment/Quiz Deadline for {cls['Class Name']}", key=f'assignment_deadline_{cls["Class Name"]}')
st.session_state.classes[-1]["Assignment Deadline"] = assignment_deadline
# Display the timetable if classes have been added
if st.session_state.classes:
st.header("Your Timetable")
timetable_df = pd.DataFrame(st.session_state.classes)
st.dataframe(timetable_df.style.set_table_attributes('style="color: black; background-color: rgba(255, 255, 255, 0.8);"'))
# Calculate suggested times to complete assignments based on deadlines
st.header("Suggested Times to Complete Assignments")
for cls in st.session_state.classes:
deadline = cls["Deadline"]
today = datetime.now().date()
remaining_days = (deadline - today).days
if remaining_days > 0:
suggested_time = datetime.now() + timedelta(hours=remaining_days * 2) # Suggesting 2 hours per remaining day
st.write(f"**{cls['Class Name']}**: Suggested completion time for assignments is {suggested_time.strftime('%Y-%m-%d %H:%M')}.")
# Option to reset the timetable
if st.button("Reset Timetable"):
st.session_state.classes.clear()
st.experimental_rerun()