繁体   English   中英

显示整个数据库数据tkinter sqlite3

[英]show whole database data tkinter sqlite3

我试图在窗口上打印数据库中的历史记录,但是我的程序仅显示两行(甚至没有排序)。 有什么问题? 打印时,我可以正确获取数据,但无法在窗口上获取它们。 对我而言,这没有任何意义。

                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

由于索引错误,因此无法正确地遍历小部件。 更改:

index=+1

至:

index += 1

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM