ilsa15 commited on
Commit
99747f3
Β·
verified Β·
1 Parent(s): 7fb058b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +73 -0
app.py ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import matplotlib.pyplot as plt
4
+ from datetime import date
5
+
6
+ # Configure Streamlit page
7
+ st.set_page_config(page_title="Productivity Tracker", layout="centered")
8
+ st.markdown("<h1 style='text-align: center; color: #2C3E50;'>πŸ—“οΈ Daily Productivity Tracker</h1>", unsafe_allow_html=True)
9
+ st.markdown("<p style='text-align: center; color: gray;'>Track your tasks, working hours, and daily notes with clean summaries and visuals</p>", unsafe_allow_html=True)
10
+
11
+ # Initialize session data
12
+ if "data" not in st.session_state:
13
+ st.session_state.data = []
14
+
15
+ # --- Input Form ---
16
+ st.markdown("### βž• Add New Entry")
17
+ with st.form("entry_form", clear_on_submit=True):
18
+ col1, col2 = st.columns(2)
19
+ with col1:
20
+ task = st.text_input("πŸ“ Task Description")
21
+ with col2:
22
+ hours = st.number_input("⏱️ Hours Worked", min_value=0.0, step=0.5)
23
+
24
+ notes = st.text_area("🧾 Short Notes", height=100)
25
+ submitted = st.form_submit_button("Add Task", use_container_width=True)
26
+
27
+ # Save data
28
+ if submitted and task:
29
+ today = date.today().strftime("%Y-%m-%d")
30
+ st.session_state.data.append({
31
+ "Date": today,
32
+ "Task": task,
33
+ "Hours": hours,
34
+ "Notes": notes
35
+ })
36
+ st.success("βœ… Task added successfully!")
37
+
38
+ # Convert to DataFrame
39
+ df = pd.DataFrame(st.session_state.data)
40
+
41
+ # --- Show Data ---
42
+ if not df.empty:
43
+ st.markdown("---")
44
+ st.markdown("### πŸ“‹ All Logged Entries")
45
+ st.dataframe(df, use_container_width=True)
46
+
47
+ st.markdown("### πŸ“ˆ Productivity Overview")
48
+ daily_summary = df.groupby("Date")["Hours"].sum().reset_index()
49
+
50
+ fig, ax = plt.subplots(figsize=(8, 4))
51
+ ax.plot(daily_summary["Date"], daily_summary["Hours"], marker='o', color="#3498DB", linewidth=2)
52
+ ax.set_title("Hours Worked Per Day", fontsize=14)
53
+ ax.set_xlabel("Date", fontsize=12)
54
+ ax.set_ylabel("Total Hours", fontsize=12)
55
+ ax.grid(True)
56
+ plt.xticks(rotation=45)
57
+ st.pyplot(fig)
58
+
59
+ st.markdown("### πŸ“Š Summary Statistics")
60
+ col1, col2, col3 = st.columns(3)
61
+ with col1:
62
+ st.metric("Total Tasks", len(df))
63
+ with col2:
64
+ st.metric("Total Hours", f"{df['Hours'].sum():.1f}")
65
+ with col3:
66
+ avg = df.groupby("Date")["Hours"].sum().mean()
67
+ st.metric("Avg Hours/Day", f"{avg:.2f}")
68
+ else:
69
+ st.warning("No entries yet. Start by adding a task above.")
70
+
71
+ # --- Footer ---
72
+ st.markdown("---")
73
+ st.markdown("<p style='text-align: center; color: #95A5A6;'>© 2025 Productivity Tracker | Built with ❀️ in Streamlit</p>", unsafe_allow_html=True)