import tkinter as tk
import tksheet
top = tk.Tk()
sheet = tksheet.Sheet(top)
sheet.grid()
tmin=10
tmax=100
incr=10
ran=int((tmax-tmin)/incr)
for i in range(ran):
d=2*(i 1)
c=2*d
sheet.set_sheet_data([d][c])
I got error
line 20, in
sheet.set_sheet_data([d][c])
IndexError: list index out of range
why this error is presented
how to fix this error
I got error
line 20, in
sheet.set_sheet_data([d][c])
IndexError: list index out of range
why this error is presented
how to fix this error
CodePudding user response:
Based on your description in your comment, what you need is to create a 2-D list using the for loop and then use sheet.set_sheet_data()
to set the table data:
import tkinter as tk
import tksheet
top = tk.Tk()
sheet = tksheet.Sheet(top)
sheet.grid()
tmin = 10
tmax = 100
incr = 10
ran = int((tmax - tmin) / incr)
# create the table data
data = []
for i in range(ran):
d = 2 * (i 1)
c = 2 * d
data.append([c, d])
# set the table data of the sheet
sheet.set_sheet_data(data)
top.mainloop()