Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import bpy
- from threading import Timer,Thread,Event #importation des fonction Timer, Thread et Event de la biblio threadingrom threading import Timer,Thread,Event #importation des fonction Timer, Thread et Event de la biblio threading
- class changiColorTimer():#création de la classe du timer
- def __init__(self,time,fonction):#initialisation des arguments de la fonction
- self.time = time#création des sous variable qui pouron etre utilsé dans les sous fonction(def)
- self.fonction = fonction
- self.thread = Timer(self.time,self.handle_function) #intialisation d'un timer de time seconde et je comprent pas le handle_function
- def handle_function(self):#definition de la fonction handle_function qu je conprend pas
- self.fonction() #c'est la même que celle de def_init
- self.thread = Timer(self.time,self.handle_function)
- self.thread.start()#demarage du Timer
- def start(self):#définition de la sous fonction start qui demare le timer
- self.thread.start()
- def stop(self):#fonction stopent le timer(avec reste du temps)
- self.thread.cancel()
- def fonction_a_executer():#fonction étant executer fors de la fint du timer(no redemarent pas le Timer
- print("timer fini")#ecrire juste dans la console que le timer a fait un tour
- t= changiColorTimer(5,fonction_a_executer)#à ce moment il lance la class(ou fonction) changiColorTimer avec comme arguments le temps toatl "5" et la fonction à exectuer après que le timer soit fini (fonction_a_executer)
- t.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement