commit 73fdc0dbf5806152e08e3f45a75038f1ef52a89a Author: Mylloon <29067904+Mylloon@users.noreply.github.com> Date: Sat Nov 28 14:08:34 2020 +0100 Add files via upload diff --git a/compteur.py b/compteur.py new file mode 100644 index 0000000..ebc15f0 --- /dev/null +++ b/compteur.py @@ -0,0 +1,53 @@ +from tkinter import * +import tkinter.font as tkfont + +class Compteur: + + def __init__(self): + self.n = 0 + self.continuer = True + self.x_n = 0 + self.y_n = 0 + + def set_taille(self): + self.taille = tkfont.Font(size=30) + + def compteur(self): + self.printN = Label(self.fenetre, text=str(self.n)+" ", font=self.taille) + self.printN.place(x=self.x_n, y=self.y_n) + self.n += 1 + if self.n == 11: + self.n = 0 + if self.continuer == True: + self.fenetre.after(100, self.compteur) + + def stop(self): + if self.continuer == False: + self.continuer = True + self.compteur() + self.stopN = Button(self.fenetre, text="Stop", command=self.stop) + self.stopN.place(x=100, y=0) + elif self.continuer == True: + self.continuer = False + self.stopN = Button(self.fenetre, text="Start", command=self.stop) + self.stopN.place(x=100, y=0) + + def start(self): + self.fenetre = Tk() + self.fenetre.title("") + self.fenetre.geometry("150x50") + + self.set_taille() + + self.printN = Label(self.fenetre, text=self.n, font=self.taille) + self.printN.place(x=self.x_n, y=self.y_n) + + self.stopN = Button(self.fenetre, text="Stop", command=self.stop) + self.stopN.place(x=100, y=0) + + self.compteur() + + self.fenetre.mainloop() + +if __name__ == '__main__': + Compteur().start()