I am brand new to Tkinter, and cant figure out how to create multiple buttons by organizing them in a list. I was able to get a single button appear, but when I try to create multiple, it doesn't work, creating a blank page instead.
from tkinter import *
from V2cboard import *
import time
#blueLength=len(blueTokens) # This is the num of blue tokens left on board
#redLength=len(redTokens) # This is the num of red tokens left on board
DispTXT=["Play as Red!","Play as Blue!","Let the Computer play!","Two players!"]
button=[None]
root=Tk()
for i in range(4):
button[i] = Button(root, text=DispTXT[i], command=boardWindow(i))
button[i].pack()
root.mainloop()
Please understand that I am new to coding and Tkinter in general.
What I expected to happen was for 4 separate buttons to be created in the window, each with the text from the list above displayed. Then when one would be clicked, it would send the number (i) to my function boardWindow to do something else. I cant get the buttons to appear though, so I thought this might be a syntax error or me misunderstanding how the Button function works? I get the error
can't invoke "button" command: application has been destroyed
when I try to create the buttons?