an2022.py

Created by schraf

Created on September 10, 2022

1.01 KB

Calendrier 2022

Utilisez les flèches haut et bas pour naviguer dans le calendrier.

Ma playlist Youtube consacrée à la NUMWORKS

Explications du programme

from kandinsky import draw_string, fill_rect
from ion import keydown,KEY_UP,KEY_DOWN
from time import sleep

nbjMois = "303232332323" # 28 + nb de jours dans le mois (28+3 pour janv, 28 + 0 pour  février etc.)
jSem = "LMmJVSD"
mois = "Janv,Fev, Mars,Avril,Mai,Juin,Juill,Aout,Sept,Oct,Nov,Dec".split(',')

def aff(d):
    nb = 0
    v = 5 # le 1/1/2022 etait un vendredi
    for i in range(d): v += int(nbjMois[i]) # on cherche le 1er du mois n°d
    v %= 7
    while nb < 2: # Affichage de 2 mois
        m = d + nb
        for i,js in enumerate(jSem): # Ligne des jours de la semaine
            draw_string(js,10 + 30 * i, 5 + 110 * nb)
        l = 1
        for j in range(28 + int(nbjMois[m])): # on parcourt tous les jours du mois
            pos = jSem.index(jSem[v]) # dans quelle colonne est ce jour de la semaine ?
            draw_string(str(j + 1),10 + 30 * pos, 5 + 110 * nb + 15 * l)
            v = (v + 1) % 7
            if pos == 6: l += 1 # Si dimanche on passe à la ligne suivante
        draw_string(mois[m], 250, 110 * nb + 30)
        nb += 1

def eff():
    fill_rect(0,0,320,222,(255,255,255))
    sleep(.2)

def key(): # attente touche
  while True:
    for (i, k) in enumerate([KEY_UP,KEY_DOWN]):
      if keydown(k): return 2 * i - 1 # renvoyer -1 ou +1

d = 0
while True:
    aff(d)
    t = key()
    d = (d + 2 * t) % 12 # on avance ou recule dans le calendrier
    eff()


from kandinsky import draw_string, fill_rect
from ion import keydown,KEY_UP,KEY_DOWN
from time import sleep

nbjMois = "303232332323"
jSem = "LMmJVSD"
mois = "Janv,Fev, Mars,Avril,Mai,Juin,Juill,Aout,Sept,Oct,Nov,Dec".split(',')

def aff(d):
    nb = 0
    v = 5 # mettre 6 en 2023
    for i in range(d): v += int(nbjMois[i])
    v %= 7
    while nb < 2:
        m = d + nb
        for i,js in enumerate(jSem):
            draw_string(js,10 + 30 * i, 5 + 110 * nb)
        l = 1
        for j in range(28 + int(nbjMois[m])):
            pos = jSem.index(jSem[v])
            draw_string(str(j + 1),10 + 30 * pos, 5 + 110 * nb + 15 * l)
            v = (v + 1) % 7
            if pos == 6: l += 1
        draw_string(mois[m], 250, 110 * nb + 30)
        nb += 1

def eff():
    fill_rect(0,0,320,222,(255,255,255))
    sleep(.2)

def key():
  while True:
    for (i, k) in enumerate([KEY_UP,KEY_DOWN]):
      if keydown(k): return 2 * i - 1

d = 0
while True:
    aff(d)
    t = key()
    d = (d + 2 * t) % 12
    eff()

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 cookies policy.