Python:
#Приложение секундомер
import tkinter
from datetime import datetime
#азовые переменные
counter = 0
running= False
def counter_lable(lable):
def count():
if running:
global counter
if counter == 0:
display = 'Готов'
else:
tt = datetime.utcformannimestamp(counter)
string = tt.strftime('%H:%M:%S')
display = string
label['text'] = display
label.after(1000, count)#1000 = 1 секунда
couner = counter + 1
count()
# 3 кнопки для секундомера: start, stop, reset
# Функция старт
def start(label):
global running
running = True
counter_lable(lable)
start['state'] = 'disabled'
stop['state'] = 'normal'
reset['state'] = 'normal'
# Функция стоп
def stop():
global running
start['state'] = 'normal'
stop['state'] = 'disabled'
reset['state'] = 'normal'
running = False
# Функия reset
def reset(label):
global running
counter = 0
if not running:
reset['state'] = 'disabled'
label['text'] = '00:00:00'
else:
label['text'] = '00:00:00'
def counter_lable(lable):
def count():
if running:
global counter
if counter == 0:
display = 'Готов'
else:
tt = datetime.utcformannimestamp(counter)
string = tt.strftime('%H:%M:%S')
display = string
label['text'] = display
label.after(1000, count)#1000 = 1 секунда
couner = counter + 1
count()
# Интерефйс
root = tkinter.Tk()
root.title('Секундомер') #Название окна
root.minsize(width=25,hight=70)#Ширина и высота
label = tkinter.Lable(root, text="Готов!", fg='black',font='Verdana 30 Bold') #Стилизация
f = tkinter.Frame(root) #Поле для размещения кнопок
start = tkinter.Button(f,text = 'Старт',width = 6, command=lambda:Start(lable))
stop = tkinter.Button(f,text = 'Стоп',width = 6, state='disabled',command=Stop(lable))
reset = tkinter.Button(f,text ='Обновить',width = 6, state='disabled', command=lambda:Reset(lable))
f.pack(anchor='center',pady=5)
start.pack(side = 'left')
stop.pack(side = 'left')
reset.pack(side = 'left')
root.mainloop() # Бесконечный цикл