Advertisement
Guest User

Untitled

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