Update app.py
Browse files
app.py
CHANGED
|
@@ -19,43 +19,70 @@ col = db["Tasks"]
|
|
| 19 |
# )
|
| 20 |
|
| 21 |
|
| 22 |
-
task_values = {
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
}
|
| 28 |
|
| 29 |
-
if st.button("Create Task"):
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
|
| 34 |
|
| 35 |
# if st.button("notify"):
|
| 36 |
# st.toast("You have a new reminder")
|
| 37 |
|
| 38 |
|
| 39 |
-
import
|
|
|
|
| 40 |
|
| 41 |
-
def
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
|
|
|
|
|
|
| 45 |
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
# Calculate the time difference between the current time and the reminder time.
|
| 48 |
-
time_diff =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
|
|
|
| 53 |
|
| 54 |
-
#
|
| 55 |
-
|
| 56 |
|
| 57 |
-
#
|
| 58 |
-
|
|
|
|
| 59 |
|
|
|
|
|
|
|
|
|
|
| 60 |
|
|
|
|
|
|
|
| 61 |
|
|
|
|
|
|
|
|
|
| 19 |
# )
|
| 20 |
|
| 21 |
|
| 22 |
+
# task_values = {
|
| 23 |
+
# "title" : st.text_input("Task Title"),
|
| 24 |
+
# "prio" : st.text_input("Priority"),
|
| 25 |
+
# "duedate" : st.text_input("Due Date"),
|
| 26 |
+
# "status" : False
|
| 27 |
+
# }
|
| 28 |
|
| 29 |
+
# if st.button("Create Task"):
|
| 30 |
+
# col.insert_one(task_values)
|
| 31 |
+
# st.success("Task Created Successfully!")
|
| 32 |
+
# st.balloons()
|
| 33 |
|
| 34 |
|
| 35 |
# if st.button("notify"):
|
| 36 |
# st.toast("You have a new reminder")
|
| 37 |
|
| 38 |
|
| 39 |
+
import streamlit as st
|
| 40 |
+
from datetime import datetime
|
| 41 |
|
| 42 |
+
def create_reminder(reminder_message, reminder_time):
|
| 43 |
+
# Create a reminder object.
|
| 44 |
+
reminder = {
|
| 45 |
+
"message": reminder_message,
|
| 46 |
+
"time": reminder_time
|
| 47 |
+
}
|
| 48 |
|
| 49 |
+
# Store the reminder in a database.
|
| 50 |
+
# ...
|
| 51 |
+
|
| 52 |
+
# Return the reminder object.
|
| 53 |
+
return reminder
|
| 54 |
+
|
| 55 |
+
def show_reminder_notification(reminder):
|
| 56 |
# Calculate the time difference between the current time and the reminder time.
|
| 57 |
+
time_diff = reminder["time"] - datetime.now()
|
| 58 |
+
|
| 59 |
+
# If the time difference is less than or equal to 0, then show the reminder notification.
|
| 60 |
+
if time_diff <= 0:
|
| 61 |
+
# Create a Streamlit toast message.
|
| 62 |
+
toast = st.toast(reminder["message"], icon="ℹ️")
|
| 63 |
+
|
| 64 |
+
# Add buttons to the toast message to track the reminder as done or notdone.
|
| 65 |
+
done_button = st.button("Done")
|
| 66 |
+
notdone_button = st.button("Not done")
|
| 67 |
|
| 68 |
+
# If the done button is pressed, then mark the reminder as done.
|
| 69 |
+
if done_button:
|
| 70 |
+
# Update the reminder in the database as done.
|
| 71 |
+
# ...
|
| 72 |
|
| 73 |
+
# Close the toast message.
|
| 74 |
+
toast.close()
|
| 75 |
|
| 76 |
+
# If the notdone button is pressed, then dismiss the toast message.
|
| 77 |
+
elif notdone_button:
|
| 78 |
+
toast.close()
|
| 79 |
|
| 80 |
+
# Get the user input for the reminder message and the time to remind.
|
| 81 |
+
reminder_message = st.text_input("Enter reminder message:")
|
| 82 |
+
reminder_time = st.time_input("Enter reminder time:")
|
| 83 |
|
| 84 |
+
# Create a reminder object.
|
| 85 |
+
reminder = create_reminder(reminder_message, reminder_time)
|
| 86 |
|
| 87 |
+
# Show the reminder notification at the specified time.
|
| 88 |
+
show_reminder_notification(reminder)
|