I want when I click an image button it runs a function and check if the button image is, let's say, equal to img1
:
Button
code
b1 = Button(root, image=img1, bd=0, bg='#292424', activebackground='#292424',
command=lambda: press(b1))
CodePudding user response:
Why not made a function with a variable. After the first click the variable equal 1 and the second click the variable equals 0?
Edit: I use this for my toggle button:
self.intervention_conciliation = tk.Button(frame_1, text="Non",
command=self.clic_boutton_conciliation)
def clic_boutton_conciliation(self):
# on va changer la couleur du bouton ainsi que l'inscription
if self.intervention_conciliation["bg"] == "SystemButtonFace":
self.intervention_conciliation["bg"] = "dim gray"
self.intervention_conciliation["text"] = "Oui"
else:
self.intervention_conciliation["bg"] = "SystemButtonFace"
self.intervention_conciliation["text"] = "Non"