Bonjour à tous,

J'aimerai afficher ou non une grille dans la fenêtre ci dessous:

Nom : 2020_05_08_17_06_08_Heating_Draw.png
Affichages : 1220
Taille : 26,2 Ko

Voici une partie du code que j'utilise:

Code python : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 
 
def print_grid():
    for x in range(25, width_w - 25, 15):
        for y in range(25, height_w - 25, 15):
            canvas.create_rectangle(x, y, x + 15, y + 15,
                                    width=2, outline='grey',
                                    fill='white',
                                    tag='square')
 
Frame1 = Frame(root, borderwidth=3, relief=GROOVE)
Frame1.pack(side='top', padx=10, pady=10)
 
Label(Frame1, text="Option de la grille").pack(padx=10,pady=10)
Button(Frame1, text="Afficher", fg='navy', command=print_grid).pack(side=LEFT, padx=10, pady=10)
Button(Frame1, text="Effacer", fg='navy', command=print_grid).pack(side=RIGHT, padx=10, pady=10)
 
# Association clic/action
canvas.bind("<Button-1>", action_clic_souris)
root.mainloop()

Je ne sais pas comment faire pour que mon deuxième bouton annule l'action du premier ? Est ce que quelqu'un sait m'aider ?

Merci