使用 Sqlite 数据填充 Tcl Treeview
我正在构建一个读取 Sqlite Db 的 Tcl 应用程序。目前,我可以使用 Tcl 前端将数据输入数据库。现在,我试图弄清楚如何从 Tcl 前端显示 Sqlite Db 中的数据。
经过一些研究,我发现树视图小部件可以很好地满足我的需求。我现在有以下代码:
set z1 [ttk::treeview .c1.t1 -columns {1 2} -show headings]
$z1 heading #1 -text "First Name"
$z1 heading #2 -text "Last Name"
proc Srch {} {global z1
sqlite3 db test.db
pack $z1
db close
}
当执行“Srch”过程(按钮事件)时,树视图 (z1) 出现,标题为名字和姓氏。此外,Sqlite Db 已连接,然后关闭。
我想添加代码,在连接到数据库和打包树视图(z1)之间从 Sqlite 数据库填充树视图。有谁知道使用 Sqlite 数据填充 Tcl 树视图的正确语法?
I am building a Tcl application that reads off of a Sqlite Db. Currently, I can enter data into the database using the Tcl frontend. Now, I am trying to figure out how to display the data within the Sqlite Db from the Tcl frontend.
After a little bit of research, I found that the treeview widget would work well for my needs. I now have the following code:
set z1 [ttk::treeview .c1.t1 -columns {1 2} -show headings]
$z1 heading #1 -text "First Name"
$z1 heading #2 -text "Last Name"
proc Srch {} {global z1
sqlite3 db test.db
pack $z1
db close
}
When the "Srch" procedure is executed (button event), the treeview (z1) appears with the headings First Name and Last Name. Additionally, the Sqlite Db gets connected, then closes.
I wanted to add code that would populate the treeview from the Sqlite Db between connecting to the Db and packing the treeview (z1). Does anyone know the correct syntax to populate a Tcl treeview with data from Sqlite?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最好这样做:
这利用了 SQLite 与 Tcl 确实非常好的集成这一事实。
Better to do this:
This uses the fact that SQLite integrates very nicely with Tcl indeed.
经过几个小时的反复试验,我终于弄清楚如何使用 sqlite 数据填充树视图小部件。不幸的是,我找不到任何网络资源,所以如果其他人遇到这个问题,答案如下:
基本上,z1 是多列列表(树),Srch 是按钮驱动程序。执行时,树中将填充与每一列相对应的名字和姓氏。
After a few hours of trial and error, I finally figured out how to populate a treeview widget with sqlite data. Unfortunately, I could not find any web resources so in case anyone else has this problem, the answer is as follows:
Basically, z1 is multi-column list (tree) and Srch is the button driven procedure. When executed the tree gets populated with first and last names, corresponding to each column.