From 9fdc37fffd0bb773074767669b3e35cd5b3aeb70 Mon Sep 17 00:00:00 2001 From: Christophe C Date: Fri, 1 Mar 2024 21:42:30 +0100 Subject: [PATCH] =?UTF-8?q?mise=20en=20place=20du=20changement=20de=20cole?= =?UTF-8?q?ur=20du=20bouton=20apr=C3=A8s=20un=20clic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GestionDes.py | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/GestionDes.py b/GestionDes.py index 11b514e..69a6d73 100644 --- a/GestionDes.py +++ b/GestionDes.py @@ -19,14 +19,54 @@ cadreFormatDe.pack(side=tk.TOP, anchor=tk.CENTER, pady=10) DicoBoutons = {} # création d'un Dico pour distingués les boutons for i in [4, 6, 8, 10, 12, 20] : - button = tk.CTkButton(cadreFormatDe, text= f"D{i}", width=3) # création d'un bouton + button = tk.CTkButton(cadreFormatDe, text= f"D{i}", hover=False, width=3) # création d'un bouton button.pack(side=tk.LEFT, padx=5, pady=5) #expand=True, fill=tk.X, anchor=tk.CENTER DicoBoutons[i] = button def clic4 (): - print("D4") + print("D4") + for i in [4, 6, 8, 10, 12, 20] : + DicoBoutons[i].configure(fg_color="blue") + DicoBoutons[4].configure(fg_color="red") + +def clic6 (): + print("D6") + for i in [4, 6, 8, 10, 12, 20] : + DicoBoutons[i].configure(fg_color="blue") + DicoBoutons[6].configure(fg_color="red") + +def clic8 (): + print("D8") + for i in [4, 6, 8, 10, 12, 20] : + DicoBoutons[i].configure(fg_color="blue") + DicoBoutons[8].configure(fg_color="red") + +def clic10 (): + print("D10") + for i in [4, 6, 8, 10, 12, 20] : + DicoBoutons[i].configure(fg_color="blue") + DicoBoutons[10].configure(fg_color="red") + +def clic12 (): + print("D12") + for i in [4, 6, 8, 10, 12, 20] : + DicoBoutons[i].configure(fg_color="blue") + DicoBoutons[12].configure(fg_color="red") + +def clic20 (): + print("D20") + for i in [4, 6, 8, 10, 12, 20] : + DicoBoutons[i].configure(fg_color="blue") + DicoBoutons[20].configure(fg_color="red") + DicoBoutons[4].configure(command=clic4) +DicoBoutons[6].configure(command=clic6) +DicoBoutons[8].configure(command=clic8) +DicoBoutons[10].configure(command=clic10) +DicoBoutons[12].configure(command=clic12) +DicoBoutons[20].configure(command=clic20) + # print(DicoBoutons)