Advertisement
Jules_de_Cube

Untitled

Jan 12th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.57 KB | None | 0 0
  1. import bpy
  2. 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
  3.  
  4. class changiColorTimer():#création de la classe du timer
  5.    
  6.     def __init__(self,time,fonction):#initialisation des arguments de la fonction
  7.         self.time = time#création des sous variable qui pouron etre utilsé dans les sous fonction(def)
  8.         self.fonction = fonction
  9.         self.thread = Timer(self.time,self.handle_function) #intialisation d'un timer de time seconde et je comprent pas le handle_function
  10.        
  11.     def handle_function(self):#definition de la fonction handle_function qu je conprend pas
  12.         self.fonction() #c'est la même que celle de def_init
  13.         self.thread = Timer(self.time,self.handle_function)
  14.         self.thread.start()#demarage du Timer
  15.        
  16.     def start(self):#définition de la sous fonction start qui demare le timer
  17.         self.thread.start()
  18.        
  19.     def stop(self):#fonction stopent le timer(avec reste du temps)
  20.         self.thread.cancel()
  21.        
  22.  
  23. def fonction_a_executer():#fonction étant executer fors de la fint du timer(no redemarent pas le Timer
  24.     print("timer fini")#ecrire juste dans la console que le timer a fait un tour
  25.    
  26.  
  27. 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)
  28. t.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement