I am working on a tkinter project and am having issues creating a number of buttons using a for loop. When I try to create buttons within a loop, I get the error 'list' object has no attribute 'tk'. I am using two lists generated from a table in db browser which I have shown below. The second part is where the error is occuring. If I remove the RewardButton generator, then no error occurs so I believe it takes issue with this specific line
conn = sqlite3.connect("Scheduling.db")
c = conn.cursor()
c.execute("select reward from rewards where Cu_ID=?",(ID))
rewards = c.fetchall()
c.execute("select points from rewards where Cu_ID=?",(ID))
points = c.fetchall()
c.close()
rewardlist=[]
for l in rewards:
rewardlist.append(l)
pointlist=[]
for p in points:
pointlist.append(p)
buttonnum=len(rewardlist)
for x in range(buttonnum):
rowpos = x+5
reward = rewardlist[x]
point = pointlist[x]
RewardButton[x] = Button(rewards, text ="Button",command = lambda k=x: RedeemReward(k))
RewardButton[x].grid(row=rowpos, column=3)