title: Change the text color depending on timedelta
body: <p>I programmed some timers and visualize these with tkinter based on code that I found on the Internet. This still worked fine for me but now I need to add a function. If the global timer variables (timedelta_amp and so on) are lower than 3 minutes I would like to change the fontcolour of the timer. Because I don't understand the copied code hundred percent I am not able to add this function.</p>
  <pre><code># importing whole module 
  from tkinter import * 
  # importing strftime function to 
  # retrieve system's time 
  from time import strftime
  # importing datetime modul
  from datetime import datetime, timedelta, time
  # close the tkinter windwo with escape
  def close_escape(event=None):
      print(&quot;escaped&quot;)
      root.destroy()
  root = Tk()
  root.title(&quot;Countdown Intraday Handel - Stunden Produkte&quot;) 
  root.attributes(&quot;-fullscreen&quot;, False) 
  root.bind(&quot;&lt;Escape&gt;&quot;, close_escape)
  root.configure(background='orange')
  
  Text = Label(root, font=('arial', 75, 'bold'), fg='white',bg='orange')
  Text.pack()
  Frame = Label(root, font=('arial', 20, 'bold'), fg='white',bg='orange')
  Frame.pack()
  
  Text1 = Label(root, font=('arial', 50, 'italic'), fg='white',bg='orange')
  Text1.pack()
  clock_schedulingarea = Label(root, font=('arial',50, 'bold'), fg='white',bg='orange')
  clock_schedulingarea.pack()
  Frame1 = Label(root, font=('arial', 20, 'bold'), fg='white',bg='orange')
  Frame1.pack()
  
  Text2 = Label(root, font=('arial', 50, 'italic'), fg='white',bg='orange')
  Text2.pack()
  clock_germany = Label(root, font=('arial', 50, 'bold'), fg='white', bg='orange')
  clock_germany.pack()
  Frame2 = Label(root, font=('arial', 20, 'bold'), fg='white',bg='orange')
  Frame2.pack()
  
  Text3 = Label(root, font=('arial', 50, 'italic'), fg='white',bg='orange')
  Text3.pack()
  clock_sidc = Label(root, font=('arial', 50, 'bold'), fg='white', bg='orange')
  clock_sidc.pack()
  
  
  def tick(): 
      global var1
      global timedelta_amp
      global var2
      global timedelta_de
      global var3
      global timedelta_sidc
      
      ActTimeMinutes = strftime(&quot;%M:%S&quot;)
      ActTimeHour = strftime(&quot;%H&quot;)
      
      ActTimeMinutesplus30 = datetime.now() + timedelta(minutes=30)
      ActTimeMinutesplus30 = ActTimeMinutesplus30.strftime(&quot;%M:%S&quot;)
      
      ActTimeHourplus1 = datetime.now() + timedelta(hours=1)
      ActTimeHourplus1 = ActTimeHourplus1.strftime(&quot;%H&quot;)
      
      ActTimeHourplus2 = datetime.now() + timedelta(hours=2)
      ActTimeHourplus2 = ActTimeHourplus2.strftime(&quot;%H&quot;)
      
      ActTimeHourplus3 = datetime.now() + timedelta(hours=3)
      ActTimeHourplus3 = ActTimeHourplus3.strftime(&quot;%H&quot;)
  
      quarter_past = &quot;14:59&quot;
      half = &quot;29:59&quot;
      quarter_to = &quot;44:59&quot;
      hour_amp = &quot;54:59&quot;
      hour = &quot;59:59&quot;
      SA = [&quot;AMP&quot;]
      SB = [&quot;DE&quot;]
      SC = [&quot;SIDC&quot;]
      
      if ActTimeMinutes &gt;= &quot;00:00&quot; and ActTimeMinutes &lt; &quot;55:00&quot;:
          var1 = [SA, ActTimeHourplus1,&quot;-&quot;, ActTimeHourplus2]
          timedelta_amp = datetime.strptime(hour_amp, &quot;%M:%S&quot;) - datetime.strptime(ActTimeMinutes, &quot;%M:%S&quot;)
      
      elif ActTimeMinutes &gt;= &quot;55:00&quot; and ActTimeMinutes &lt; &quot;59:59&quot;:
          var1 = [SA, ActTimeHourplus1,&quot;-&quot;, ActTimeHourplus2]
          timedelta_amp = (&quot;Gate Closure&quot;)
      
      
      if ActTimeMinutes &gt;= &quot;00:00&quot; and ActTimeMinutes &lt; &quot;30:00&quot; :
          var2 = [SB, ActTimeHourplus1,&quot;-&quot;, ActTimeHourplus2]
          timedelta_de = datetime.strptime(half, &quot;%M:%S&quot;) - datetime.strptime(ActTimeMinutes, &quot;%M:%S&quot;)
          
      elif ActTimeMinutes &gt;= &quot;30:00&quot; and ActTimeMinutes &lt; &quot;59:59&quot;:
          var2 = [SB, ActTimeHourplus2,&quot;-&quot;, ActTimeHourplus3]
          timedelta_de = datetime.strptime(hour, &quot;%M:%S&quot;) - datetime.strptime(ActTimeMinutesplus30, &quot;%M:%S&quot;)
              
  
      var3 = [SC, ActTimeHourplus2,&quot;-&quot;, ActTimeHourplus3]
      timedelta_sidc = datetime.strptime(hour, &quot;%M:%S&quot;) - datetime.strptime(ActTimeMinutes, &quot;%M:%S&quot;)
      
    
      Text.config(text=&quot;Stunden Produkte&quot;)
      Frame.config(text=&quot;______________________________________________________________________________________________&quot;)
      
      clock_schedulingarea.config(text=timedelta_amp)
      Text1.config(text=var1)
      Frame1.config(text=&quot;___________________________________&quot;)
      
      clock_germany.config(text=timedelta_de)
      Text2.config(text=var2)
      Frame2.config(text=&quot;___________________________________&quot;)
      
      clock_sidc.config(text=timedelta_sidc)
      Text3.config(text=var3)
      
      clock_sidc.after(20, tick)
  
  tick()
  root.mainloop()
  </code></pre>