forked from exo7math/python1-exo7
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmarkdown_code_2_2.py
More file actions
44 lines (34 loc) · 1.34 KB
/
markdown_code_2_2.py
File metadata and controls
44 lines (34 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
def afficher_ligne_v2(par,posy):
""" Affiche le texte selon le mode titre, sous-titre, texte, liste
Entrée : un paragraphe (c-à-d une longue ligne), la position verticale
Sortie : affichage """
# Par défaut : texte, sans indentation
mode = "texte"
indentation = 20
if par[0:2] == "##": # Sous_titre
mode = "sous_titre"
par = par[2:] # Supprime les ##
elif par[0] == "#": # Titre
mode = "titre"
par = par[1:] # Supprime le #
elif par[0] == "+": # liste
mode = "liste"
par = u'\u2022' + par[1:] # Remplace le "+" par un rond
indentation = 40
# Début de la ligne (décalé si liste)
posx = indentation
liste_mots = par.split()
for mot in liste_mots:
fonte = choix_fonte(mode,False,False)
mot = mot + " " # Rajoute espace qui sépare les mots
mot_canvas = canvas.create_text(posx,posy, text=mot,anchor=NW,font=fonte,fill=couleur_texte)
posx = canvas.bbox(mot_canvas)[2]
return
# Tests
afficher_ligne_v2("# Voici un titre",80)
afficher_ligne_v2("## Et ici un sous titre",115)
afficher_ligne_v2("Du texte normal, et une liste ci-dessous :",150)
afficher_ligne_v2("+ Pomme",175)
afficher_ligne_v2("+ Poire",200)
afficher_ligne_v2("+ Scoubidou",225)
root.mainloop()