{{tag>cameo plotter python}}
====== Calendrier 2026 ======
Réalisé avec la cameo 4 à partir d'un fichier vectoriel inkscape et inkscape-silhouette.
La théière est un fichier SVG classique, chque élément mensuel du calendrier a été réalisé avec un script python, puis modifié dans inkscape pour utiliser une typo adaptée au tracé.
{{:openatelier:projet:calendrier_2026:calendrier_2026_vue_generale.jpg?direct&600|}}
{{:openatelier:projet:calendrier_2026:calendrier_2026_vue_detail.jpg?direct&600|}}
**Fichier svg** (à afficher en mode contour, menu affichage / mode d'affichage / contour) : {{ :openatelier:projet:calendrier_2026:calendrier_2026.svg?linkonly |}}
===== Le script du calendrier =====
Pour chaque mois, il faut déclencher le script en indiquant le nombre de jour et le premier jour du mois, de cette manière :
python3 svg_calendrier_mensuel.py 28 dimanche
python3 svg_calendrier_mensuel.py 31 dimanche
python3 svg_calendrier_mensuel.py 30 mercredi
python3 svg_calendrier_mensuel.py 31 vendredi
python3 svg_calendrier_mensuel.py 30 lundi
python3 svg_calendrier_mensuel.py 31 mercredi
python3 svg_calendrier_mensuel.py 31 samedi
python3 svg_calendrier_mensuel.py 30 mardi
python3 svg_calendrier_mensuel.py 31 jeudi
python3 svg_calendrier_mensuel.py 30 dimanche
python3 svg_calendrier_mensuel.py 31 mardi
#!/usr/bin/env python3
# création d'un calendrier mensuel, sous forme de fichier SVG
# 7 colonnes (L, M, M, J, V, S, D) avec entête x 6 lignes
# utilisation :
# python3 calendrier.py nombre-de-jours-du-mois 1er-jour-du-mois
# python3 calendrier.py 31 jeudi
# le script demandera comment nommer le fichier SVG
# le but final est d'appliquer une police «Hershey» dans inkscape pour que le calendrier
# puisse être réalisé au plotter
#
# 23/12/2025 pierre@lesporteslogiques.net
# Debian 12 @ tenko, python 3.11.2
import sys
# Colonnes du calendrier
JOURS = ["L", "M", "M", "J", "V", "S", "D"]
JOUR_INDEX = {
"lundi": 0,
"mardi": 1,
"mercredi": 2,
"jeudi": 3,
"vendredi": 4,
"samedi": 5,
"dimanche": 6,
}
def generate_calendar_svg(nb_days, first_day, filename):
if first_day not in JOUR_INDEX:
raise ValueError("Jour invalide.")
start_col = JOUR_INDEX[first_day]
# Dimensions
cols = 7
rows = 6
cell_width = 30
cell_height = 22
header_height = 36
width = cols * cell_width
height = header_height + rows * cell_height
# Taille maximale des chiffres
day_font_size = int(cell_height * 0.6)
svg = []
svg.append(f'")
with open(filename, "w", encoding="utf-8") as f:
f.write("\n".join(svg))
if __name__ == "__main__":
if len(sys.argv) != 3:
print("Usage : python3 calendrier.py ")
sys.exit(1)
nb_jours = int(sys.argv[1])
jour_1er = sys.argv[2].lower()
filename = input("Nom du fichier SVG à créer (ex: calendrier.svg) : ").strip()
if not filename.endswith(".svg"):
filename += ".svg"
generate_calendar_svg(nb_jours, jour_1er, filename)
print(f"Fichier '{filename}' généré.")
===== Typos pour Plotter =====
Chaque calendrier est modifié dans inkscape en utilisant les polices de texte de type «Hershey» (cf. https://en.wikipedia.org/wiki/Hershey_fonts). Ces fontes ont pour caractéristiques d'être définies par un tracé central composé de lignes droites (et non pas un contour comme pour les fontes classiques)
Manip : sélectionner tout le texte, puis « extension/texte/texte Hershey », dans ce cas, c'est la police «HersheySans1» qui est utilisée.