def create_table(self, frame):
data = [['Jeremy', 'Dean', '80%', 'Asteroids', 'Jupiter'], ['Matt', 'Damon', '75%', 'Asteroids', 'Jupiter']] # sample data
i = 0
try:
for row in data:
j = 0
for item in row:
textVar = StringVar()
textVar.set(item)
# creates an entry for each piece of data
entry = Entry(frame, state='readonly',textvariable=textVar, readonlybackground='lightgrey',width=14)
entry.grid(row=i + 1, column=j)
j += 1
i += 1
except TypeError:
raise
I'm trying to create a table that will be displayed in the 'frame' frame, with the table consisting of the contents of the 2d array (so the first row would contain 'Jeremy, Dean ...', then 'Matt, Damon ...' in the second row)
Currently, whenever i run this program it outputs the entry boxes but without the text in them. It's weird because I've used this same code in another program and it worked fine but it doesn't work here.
I've tried using text=item
instead of textvariable=textVar
aswell but it doesn't seem to work for me either