I want to generate n amount of Tkinter Buttons which do different things. I have this code:
import Tkinter as tk
for i in range(boardWidth):
newButton = tk.Button(root, text=str(i+1),
command=lambda: Board.playColumn(i+1, Board.getCurrentPlayer()))
Board.boardButtons.append(newButton)
If boardWidth is 5, though I get buttons labelled 1 to 5, when clicked they all do Board.playColumn(5, Board.getCurrentPlayer()).
I need the first button to do Board.playColumn(1, Board.getCurrentPlayer()), the second to do Board.playColumn(2, Board.getCurrentPlayer()) and so on.