Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. # Importer les modules utilisé
  2. import time
  3. from multiprocessing import Process, Value
  4. import keyboard
  5.  
  6. t = {"s": 0, "m": 0, "h": 0}
  7.  
  8.  
  9. def main(a):
  10.     global t
  11.     while a.Value == 1:
  12.         t["s"] += 1
  13.         if t["s"] >= 60:
  14.             t["s"] = 0
  15.             t["m"] += 1
  16.         if t["m"] >= 60:
  17.             t["m"] = 0
  18.             t["h"] += 1
  19.  
  20.         print(str(t["h"]) + " : " + str(t["m"]) + " : " + str(t["s"]))
  21.         time.sleep(1)
  22.  
  23.  
  24. def key(a):
  25.     while a.Value == 1:
  26.         if keyboard.is_pressed("z"):
  27.             a = Value("i", 2)
  28.  
  29.  
  30. if __name__ == '__main__':
  31.     a = Value("i", 1)
  32.     p1 = Process(target=main, args=a)
  33.     p2 = Process(target=key, args=a)
  34.     p1.start()
  35.     p2.start()
  36.     p1.join()
  37.     p2.join()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement