简体   繁体   English

python sqlite3 tkinter-如何为sqlite表中的每一行自动创建新的小部件?

[英]python sqlite3 tkinter- How do I automatically create new widgets for every row in an sqlite table?

I'm working on a project that is using tkinter and sqlite3. 我正在使用tkinter和sqlite3的项目。 Inside a tk.Toplevel window I have a frame. 在tk.Toplevel窗口中,我有一个框架。 Inside that frame will be a list rows in an sqlite table (depending on how many rows are in the table). 在该框架内将是一个sqlite表中的列表行(取决于表中有多少行)。

For every row in the frame there needs to be a tk.Checkbutton, a value from the table, and two tk.Entry's. 对于框架中的每一行,都需要一个tk.Checkbutton,表中的一个值和两个tk.Entry。

Here is a (bad) picture of what it will look like if I have for example 5 rows in my table. 这是一张(不好的)图片,说明如果我的表中有5行,它将是什么样子。 http://s13.postimg.org/pt06zelpz/frame.png http://s13.postimg.org/pt06zelpz/frame.png

And if I added more rows to the sqlite table, there would be the equivalent number of rows in the tkinter frame. 而且,如果我在sqlite表中添加了更多行,则tkinter框架中的行数将相等。

How do I implement this though ? 我该如何实现呢? How do I make these widgets without naming them, or knowing how many I need before hand? 我如何在不命名它们或不知道自己需要多少的情况下制作这些小部件? Also, I need to get data from these widgets (if a checkbutton is checked and whats in the entry) for later use and manipulation. 另外,我需要从这些小部件中获取数据(如果选中了检查按钮,并且条目中有内容),以备后用和操纵。 Is this even possible? 这有可能吗?

Thanks in advance for any reply. 预先感谢您的任何答复。

Maybe this link can help: Does tkinter have a table widget? 也许此链接可以帮助您: tkinter是否有一个表格小部件? . There are some other 'grid' implementations can be found on the internet. 在互联网上可以找到其他一些“网格”实现。

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

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