ten.py

Created by schraf

Created on November 05, 2021

643 Bytes

Explications en vidéo

Réalisation de la montre suivante sur la NumWorks : https://www.tokyoflash.com/en/kisai-tenmetsu

>> go(17,29,30) pour lancer la montre avec l’heure 17h29m30s


from kandinsky import *
from time import *

def aff(x,v):
  # affiche valeur v en position x
  for i in range(10):
    if v >= 15:
      c = (255,0,0) # rouge
      v -= 15
    elif v >= 5:
      c = (255,165,0) # orange
      v -= 5
    elif v>=1:
      c = (0,255,0) # vert
      v -= 1
    else: c = (255,)*3 # blanc
    fill_rect(x + 50 * (i%2),180 - 40 * (i//2),49,39,c)  
    
def go(h=12,m=0,s=0):
  while True:
    aff(10,h)
    aff(110,m)
    aff(210,s)
    s += 1
    if s >= 60: # +1 min
      s = 0
      m += 1
    if m >= 60: # +1 heure
      m = 0
      h += 1
    if h >= 24: h = 0 
    sleep(1)  # Attente 1 seconde