Add files via upload

This commit is contained in:
Mylloon 2020-11-28 14:07:47 +01:00 committed by GitHub
commit bd120cf80d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

43
chronometre.py Normal file
View file

@ -0,0 +1,43 @@
import time
from tkinter import *
class Chronometre:
def __init__(self):
self.flag = 0
self.depart = 0
def lancer_chrono(self):
self.flag = 1
self.depart = time.time()
self.chrono()
def stopper_chrono(self):
self.flag = 0
def reset_chrono(self):
self.depart = time.time()
def chrono(self):
y = time.time() - self.depart
minutes = time.localtime(y)[4]
secondes = time.localtime(y)[5]
if self.flag :
self.message.configure(text = "%i ' %i '' " %(minutes,secondes))
self.fenetre.after(1000, self.chrono)
def start(self):
self.fenetre = Tk()
self.fenetre.title('Chronomètre')
self.message = Label(self.fenetre, font=('sans', 20, 'bold'), text="Chrono prêt")
self.message.grid(row=1)
Button(self.fenetre, text='GO !', command=self.lancer_chrono).grid(row=2)
Button(self.fenetre, text='STOP !', command=self.stopper_chrono).grid(row=3)
Button(self.fenetre, text='RESET', command=self.reset_chrono).grid(row=4)
self.fenetre.mainloop()
if __name__ == '__main__':
Chronometre().start()