I have a program that takes train departure times from a website, processes them and displays them in a new window. Now, I would like to add a feature that changes the colour of the times displayed. I am doing this with the following code: (res&res2 are the departure times)
t1 = time(0,1,0)
t2 = time(0,2,0)
def color():
f = get_resp()
g = f[1]
res = g[0]
res2 = str(res)
if res2 < t1:
return "red"
elif res2 < t2:
return "orange"
elif res2 > t2:
return "green"
Now my problem is that this code always returns "green", no matter what the times are. I've tried to convert both times into strings and then compare them, I've tried to convert both to datetime and compare them and I've tried to pick only the minutes and compare those - which didn't work because res is a timedelta.
My guess is that this is because of different formats of res and t1 / t2
res: 0:07:04
t1: 00:01:00
This is a link to the .py file of my whole code https://drive.google.com/file/d/1NK4bYgstWKumRI95AD1nP9sHRTfEhXnj/view?usp=sharing