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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
def reset_chrono():
isRunningChrono=False
my_thread_chrono.current(isRunningChrono,tActualTime,tZero)
#my_thread_chrono.stop()
chrono_label['text'] ="00:00:00"
window.update_idletasks()
def stop_chrono():
#global isRunningChrono
global tActualTime
global tZero
global my_thread_chrono
print("StopChrono")
isRunningChrono=False
window.update_idletasks()
my_thread_chrono.current(isRunningChrono,tActualTime,tZero)
for thread in enumerate():
if my_thread_chrono.isAlive():
try:
my_thread_chrono._Thread__stop()
except:
print(str(my_thread_chrono.getName()) + ' could not be terminated')
#time.sleep(5)
#window.update_idletasks()
#my_thread_chrono.stop()
class Thread_Chrono(threading.Thread):
def __init__(self, name):
threading.Thread.__init__(self)
self.name = name
def current(self, test,tActual,tZ):
global isRunningChrono
#global tActualTime
global tZero
print(tActual)
print(tZ)
self.value = test
isRunningChrono=self.value
tActualTime=tActual
print("isRunningCurrent",isRunningChrono)
tZero=tZ
pass
def run(self):
global isRunningChrono #made global here
#global tActualTime
global tZero
while True:
#print("isRunningChrono=%b",isRunningChrono)
while isRunningChrono:
print("isRunning enter")
tActualTime=time.time()-tZero
tiTuple=time.gmtime(tActualTime)
reste=tActualTime-tiTuple[3]*3600.0-tiTuple[4]*60.0-tiTuple[5]*1.0
resteS=("%.2f" % reste)[-2::]
tt=time.strftime("%H:%M:%S",tiTuple)
chrono_label['text'] =""+tt
window.update_idletasks()
print tt
time.sleep(1)
#conditionThread.release()
my_thread_chrono=Thread_Chrono("myThread_name_Chrono")
my_thread_chrono.current(isRunningChrono,tActualTime,tZero)
my_thread_chrono.start()
def myFonction():
stop_chrono() |
Partager