I'm not entirely sure how to describe my issue, so heres an example:
I have a choice_id
variable which takes an integer value 1 to 4
and 4 tkinter button elements: choice1, choice2, etc...
I want to be able to configure each button to have a different colour depending on which button has been clicked. I currently have a not very elegant solution:
if choice_id == 1:
self.choice1.configure(bg="red")
if choice_id == 2:
self.choice2.configure(bg="red")
if choice_id == 3:
self.choice3.configure(bg="red")
if choice_id == 4:
self.choice4.configure(bg="red")
is there a better way to do this?
I was thinking something like
[f"self.choice{choice_id}"].configure(bg="red")
where I woud be able to configure a certain button element that is dependent on the value of an integer
Any help would be greatly appreciated
thanks