Maybe some thing along these lines. The time for blue is set between 1 pm and 3:59 pm then changes.
import tkinter as tk from time import strftime class Clock: def __init__(self, parent=None): # following allows importing class into another GUI framework. if not parent: self.parent = tk.Tk() else: self.parent = parent self.parent.title('My Clock') self.parent.geometry('200x50+50+50') self.clock = tk.Label(self.parent, borderwidth = 2, height=2, relief=tk.SOLID) self.clock.pack(padx=5, pady=2, fill=tk.BOTH) self.clock.configure(fg='blue') self.clock['text'] = strftime("%I:%M:%S") self.time_now = strftime("%I:%M:%S") self.increnment_time() if not parent: self.parent.mainloop() def display_time(self): self.clock['text'] = strftime("%I:%M:%S") hour = strftime('%I') min = strftime('%M') # If it is between these hours fg color is blue else it is green if hour >= '13' or hour <= '15' and min <= '59': self.clock.configure(fg='blue') else: self.clock.configure(fg='green') def increnment_time(self): self.display_time() # call self every 1000 ms (1 sec) self.clock.after(1000, self.increnment_time) if __name__ == '__main__': clk = Clock()
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags