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()