Found this content helpful? Log in or sign up to leave a like!
Python GUI app to update assignment due dates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2025
11:37 AM
Hello. I am building a GUI app with Python and the tkinter library to get assignment due dates, update them, then push them back out to Canvas. My issue is that when I go to store the dates in a list, the program only stores the last date for all the dates that the user will input, instead of capturing each individually. (screenshot attached)
My code is below (I left out sensitive parts for security reasons). Hopefully it's enough to get a general idea.
I'm using Canvasapi library for my API calls.
def button_clicked():
API_URL = "https://[INSTUTION URL]"
API_KEY = MyToken.secret
canvas_api = Canvas(API_URL, API_KEY)
courseID = uinput.get()
course = canvas_api.get_course(courseID)
global dueDate
dueDate = course.get_course_level_assignment_data()
due_dates_text = ""
for stuff in dueDate:
entry = tk.Entry(assignmentName)
global entry1
entry1 = tk.Entry(dateDue)
global entry2
entry2 = tk.Entry(timeDue)
entry.insert(0, f"{stuff['title']}") #Prints out the assignment names
entry.pack()
### If statements to find the due date and time of the assignments and prints it out
if stuff['due_at'] == None:
entry1.insert(0, "No Due Date")
entry2.insert(0, "No Due Date")
entry1.pack()
entry2.pack()
elif stuff['due_at']:
entry1.insert(0, f"{stuff['due_at'].split('T')[0]}")
entry2.insert(0, f"{stuff['due_at'].split('T')[1]}")
entry1.pack()
entry2.pack()
def pushDueDate():
API_URL = "https://[institution URL]"
API_KEY = MyToken.secret
canvas = Canvas(API_URL, API_KEY)
course = canvas.get_course(uinput.get())
assignment = course.get_assignments()
date = []
time = []
for x in dueDate:
x = entry1.get()
date.append(x)
print(date)
for i in assignment:
update = i.edit(assignment={'due_at': date + 'T' + time + 'Z'})
update
print(date + ' ' + time)
print(update)