Spaces:
Sleeping
Sleeping
File size: 1,535 Bytes
1f30d46 ccc8c8f 1f30d46 ccc8c8f 1f30d46 |
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 |
import gradio as gr
from queue import PriorityQueue
from datetime import datetime
pq = PriorityQueue()
date_format = '%m-%d-%Y at %H:%M'
def writer(pair):
final = pair[1] + ' is due on '
final += f'{pair[0].month:02}-{pair[0].day:02}-{pair[0].year} at '
final += f'{pair[0].hour:02}:{pair[0].minute:02}'
return final
def string_rep(pq):
work = ""
for element in pq.queue:
work += writer(element) + '\n'
return work
def inputter(date_str = None, item_name = None, add = "Show"):
if add == "Show":
return string_rep(pq)
cur_date = datetime.strptime(date_str, date_format)
if add == "Add":
pq.put((cur_date, item_name))
else:
remove((cur_date, item_name))
return string_rep(pq)
def remove(element):
temp = PriorityQueue()
while not pq.empty():
elem = pq.get()
if elem != element:
temp.put(elem)
pq.queue = temp.queue
datebox = gr.Textbox(label="Enter your date here:", placeholder="MM-DD-YYYY at HH:MM")
hwbox = gr.Textbox(label="Enter your assignment name here:", placeholder="Work")
addbox = gr.Textbox(label="Add or Drop or Show:", placeholder="Add or Drop or Show (Case Sensitive)")
ouputbox = gr.Textbox(label="List of Assignments:", placeholder="Homework is due on MM-DD-YYYY at HH:MM", lines = 10)
iface = gr.Interface(
fn=inputter,
inputs=[datebox, hwbox, addbox],
outputs=ouputbox,
title="Work Prioritzer",
)
iface.launch()
|