Полный код (именно нужный кусок кода находится внизу):
from tkinter import *
import keyboard
from threading import *
time1 = 200
root = Tk()
root.geometry("512x128+0+256")
root['bg'] = '#101010'
root.overrideredirect(True)
root.wm_attributes("-topmost", True)
root.wm_attributes("-transparentcolor", "#101010")
label1 = Label(text = "таймер 1: None", bd = 3, font = ('Minecraft Rus', 12), background = '#000000', foreground = '#ffffff')
label1.place(x = 0, y = 24)
def timer1():
global time1
if time1 > 180:
label1 = Label(text = "таймер 1: " + str(time1) + " ", bd = 3, font = ('Minecraft Rus', 12), background = '#000000', foreground = '#ffffff')
label1.place(x = 0, y = 24)
elif time1 > 60:
label1 = Label(text = "таймер 1: " + str(time1) + " ", bd = 3, font = ('Minecraft Rus', 12), background = '#ff0000', foreground = '#ffffff')
label1.place(x = 0, y = 24)
elif time1 > 30:
label1 = Label(text = "таймер 1: " + str(time1) + " ", bd = 3, font = ('Minecraft Rus', 12), background = '#ff8000', foreground = '#ffffff')
label1.place(x = 0, y = 24)
elif time1 > 10:
label1 = Label(text = "таймер 1: " + str(time1) + " ", bd = 3, font = ('Minecraft Rus', 12), background = '#000000', foreground = '#ffff00')
label1.place(x = 0, y = 24)
elif time1 > 0:
label1 = Label(text = "таймер 1: " + str(time1) + " ", bd = 3, font = ('Minecraft Rus', 12), background = '#000000', foreground = '#00ff00')
label1.place(x = 0, y = 24)
if time1 == 0:
time1 = 200
time1 -= 1
root.after(1000, timer1)
def f4():
keyboard.wait('f4')
timer1()
f4 = Thread(target=f4).start()
root.mainloop()
time1 = 200
def timer1():
global time1
if time1 > 180:
label1 = Label(text = "таймер 1: " + str(time1) + " ", bd = 3, font = ('Minecraft Rus', 12), background = '#000000', foreground = '#ffffff')
label1.place(x = 0, y = 24)
elif time1 > 60:
label1 = Label(text = "таймер 1: " + str(time1) + " ", bd = 3, font = ('Minecraft Rus', 12), background = '#ff0000', foreground = '#ffffff')
label1.place(x = 0, y = 24)
elif time1 > 30:
label1 = Label(text = "таймер 1: " + str(time1) + " ", bd = 3, font = ('Minecraft Rus', 12), background = '#ff8000', foreground = '#ffffff')
label1.place(x = 0, y = 24)
elif time1 > 10:
label1 = Label(text = "таймер 1: " + str(time1) + " ", bd = 3, font = ('Minecraft Rus', 12), background = '#000000', foreground = '#ffff00')
label1.place(x = 0, y = 24)
elif time1 > 0:
label1 = Label(text = "таймер 1: " + str(time1) + " ", bd = 3, font = ('Minecraft Rus', 12), background = '#000000', foreground = '#00ff00')
label1.place(x = 0, y = 24)
if time1 == 0:
time1 = 200
time1 -= 1
root.after(1000, timer1)
def f4():
keyboard.wait('f4')
timer1()
f4 = Thread(target=f4).start()