Salut salut !
Bon j'essaye d'avancer désormais que je connais l'utiliter de la fonction after(), mais ici problème lorsque j'essaye d'effectuer une tache.
Mon code me sert à lorsque j'appuie sur la touche entrée, il déclenche une autre clock() mais ça ne marche pas...
Message d'erreur:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\EduPython\App\lib\tkinter\__init__.py", line 1538, in __call__
return self.func(*args)
TypeError: clock() takes 0 positional arguments but 1 was given
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| from tkinter import *
from time import *
import os
main = Tk()
main.title("Test")
main.geometry("720x480+250+250")
def clock():
x=True
while x == True:
if sec > 59:
mins = mins +1
sec = 0
sec = sec +1
mins = mins+0
sleep(1)
main.after(1000, clock)
sec = int(0)
mins = int(0)
ti_me = (mins,":",sec)
timer = Label(main, textvariable=ti_me)
x = False
main.bind("<Return>", clock)
main.mainloop() |
Partager