Update calendar.py
Browse files- calendar.py +55 -23
calendar.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import json
|
| 2 |
import datetime
|
|
|
|
| 3 |
|
| 4 |
class Calendar:
|
| 5 |
def __init__(self, filename="calendar_data.json"):
|
|
@@ -43,27 +44,58 @@ class Calendar:
|
|
| 43 |
print(f"Current date: {self.current_date}")
|
| 44 |
self.show_reminders(str(self.current_date))
|
| 45 |
|
| 46 |
-
if __name__ == "__main__":
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import json
|
| 2 |
import datetime
|
| 3 |
+
import gradio as gr
|
| 4 |
|
| 5 |
class Calendar:
|
| 6 |
def __init__(self, filename="calendar_data.json"):
|
|
|
|
| 44 |
print(f"Current date: {self.current_date}")
|
| 45 |
self.show_reminders(str(self.current_date))
|
| 46 |
|
| 47 |
+
# if __name__ == "__main__":
|
| 48 |
+
# calendar = Calendar()
|
| 49 |
+
# while True:
|
| 50 |
+
# print("\nCalendar Menu:")
|
| 51 |
+
# print("1. Add Reminder")
|
| 52 |
+
# print("2. Show Reminders")
|
| 53 |
+
# print("3. Browse Calendar")
|
| 54 |
+
# print("4. Exit")
|
| 55 |
+
# choice = input("Choose an option: ")
|
| 56 |
|
| 57 |
+
# if choice == "1":
|
| 58 |
+
# date = input("Enter date (YYYY-MM-DD): ")
|
| 59 |
+
# reminder = input("Enter reminder: ")
|
| 60 |
+
# calendar.add_reminder(date, reminder)
|
| 61 |
+
# elif choice == "2":
|
| 62 |
+
# date = input("Enter date (YYYY-MM-DD): ")
|
| 63 |
+
# calendar.show_reminders(date)
|
| 64 |
+
# elif choice == "3":
|
| 65 |
+
# days = int(input("Enter number of days to move (positive for forward, negative for backward): "))
|
| 66 |
+
# calendar.browse_calendar(days)
|
| 67 |
+
# elif choice == "4":
|
| 68 |
+
# break
|
| 69 |
+
# else:
|
| 70 |
+
# print("Invalid option. Please try again.")
|
| 71 |
+
|
| 72 |
+
calendar = Calendar()
|
| 73 |
+
|
| 74 |
+
def add_reminder_interface(date, reminder):
|
| 75 |
+
return calendar.add_reminder(date, reminder)
|
| 76 |
+
|
| 77 |
+
def show_reminders_interface(date):
|
| 78 |
+
return calendar.show_reminders(date)
|
| 79 |
+
|
| 80 |
+
# Gradio UI
|
| 81 |
+
with gr.Blocks() as demo:
|
| 82 |
+
gr.Markdown("# Simple Calendar App")
|
| 83 |
+
|
| 84 |
+
with gr.Row():
|
| 85 |
+
date_input = gr.Textbox(label="Enter Date (YYYY-MM-DD)")
|
| 86 |
+
reminder_input = gr.Textbox(label="Enter Reminder")
|
| 87 |
+
add_button = gr.Button("Add Reminder")
|
| 88 |
+
|
| 89 |
+
output_text = gr.Textbox(label="Output")
|
| 90 |
+
|
| 91 |
+
add_button.click(add_reminder_interface, inputs=[date_input, reminder_input], outputs=output_text)
|
| 92 |
+
|
| 93 |
+
with gr.Row():
|
| 94 |
+
date_query = gr.Textbox(label="Check Reminders for Date")
|
| 95 |
+
check_button = gr.Button("Show Reminders")
|
| 96 |
+
|
| 97 |
+
reminder_output = gr.Textbox(label="Reminders")
|
| 98 |
+
|
| 99 |
+
check_button.click(show_reminders_interface, inputs=[date_query], outputs=reminder_output)
|
| 100 |
+
|
| 101 |
+
demo.launch()
|