cordonsolution8
2022-12-09 10:58:00
https://image.noelshack.com/fichiers/2022/49/5/1670579813-screenshot-2022-12-09-10-56-40-655-org-mozilla-firefox.jpgpetit joueurs, chatgpt master race en python en plus d'être gratuit
from tkinter import *
import time
class Timer:
def __init__(self, master):
self.master = master
master.title("Chronomètre")
self.total_time = 0
self.running = False
self.start_button = Button(master, text="On", command=self.start)
self.start_button.pack()
self.stop_button = Button(master, text="Off", command=self.stop)
self.stop_button.pack()
self.reset_button = Button(master, text="Rw", command=self.reset)
self.reset_button.pack()
self.time_label = Label(master, text="0:00:00")
self.time_label.pack()
def start(self):
self.running = True
# Mettre à jour l'affichage du temps chaque seconde
self.update_time()
def stop(self):
self.running = False
def reset(self):
self.total_time = 0
self.time_label["text"] = "0:00:00"
def update_time(self):
if self.running:
self.total_time += 1
# Formater le temps sous la forme hh:mm:ss
time_str = "{:02d}:{:02d}:{:02d}".format(
self.total_time // 3600,
self.total_time % 3600 // 60,
self.total_time % 60
)
self.time_label["text"] = time_str
# Mettre à jour l'affichage chaque seconde
self.master.after(1000, self.update_time)
root = Tk()
my_timer = Timer(root)
root.mainloop()