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

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our <a href="https://www.numworks.com/legal/cookies-policy/">cookies policy</a>.