Spaces:
Sleeping
Sleeping
File size: 1,420 Bytes
d112e03 d70b6d1 d112e03 a1ecdea d112e03 f471cec d112e03 f471cec d112e03 f471cec d112e03 eb51b31 d112e03 a1ecdea d112e03 f471cec eb51b31 e84c3c9 eb51b31 f471cec ef85d88 f471cec 7b0a13a ef85d88 d112e03 f471cec 7b0a13a b570630 d112e03 |
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 |
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, item_name, add):
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 = temp
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="Homework")
addbox = gr.Textbox(label="Add or Drop?:", placeholder="Add or Drop")
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="Homework Prioritzer",
)
iface.launch()
|