我试图打印窗口中数据库中的历史记录,但我的程序只显示两行(甚至没有订购)。问题是什么? 打印时我得到了正确的数据,但我无法在窗口上获取数据。 对我来说没有任何意义。
def his(self, database, progx):
con = sqlite3.connect(database)
with con:
cur = con.cursor()
cur.execute('SELECT * FROM ' + progx + ' ORDER BY id DESC ')
index=3
for row in cur.fetchall():
print(row) #this works just fine
Label(self, text=row[1]).grid(row=index, column=0)
Label(self, text=row[2]).grid(row=index, column=1)
Label(self, text=row[3]).grid(row=index, column=2)
Label(self, text=row[4]).grid(row=index, column=3)
Label(self, text=row[5]).grid(row=index, column=4)
Label(self, text=row[6]).grid(row=index, column=5)
Label(self, text=row[7]).grid(row=index, column=6)
Label(self, text=row[8]).grid(row=index, column=7)
Label(self, text=row[9]).grid(row=index, column=8)
Label(self, text=row[10]).grid(row=index, column=9)
Label(self, text=row[11]).grid(row=index, column=10)
Label(self, text=row[12]).grid(row=index, column=11)
Label(self, text=row[13]).grid(row=index, column=12)
Label(self, text=row[14]).grid(row=index, column=13)
hist.update()
index=+1
答案 0 :(得分:0)
它没有正确迭代小部件,因为索引是错误的。 变化:
index=+1
要:
index += 1