Once an instance of a button has been created in a loop how is an individual button or label updated? Lets say I want to change the background on the 'North' button to 'blue'.
?????????.config(bg = 'blue')
What is the button name for the 'North' button in the code below?
import tkinter as tk
def onbutton_click(label):
print('selected ', label)
lst = ['North','South','East','West']
win = tk.Tk()
win.title = 'Compass'
for col,Direction in enumerate(lst):
buttonName = tk.Button(win, text=Direction, command=lambda e=Direction: onbutton_click(e))
buttonName.grid(row=0, column=col)
win.mainloop()
This code is from another question answered by gms - thank you, that was a great answer, very clear! Tkinter create buttons from list each with its own function