【发布时间】:2017-03-09 07:48:37
【问题描述】:
我正在尝试使用 TCL/TK 创建一个表并在不使用 Tktable 小部件的情况下构建它。
我正在使用画布使用以下提供的方法从头开始构建表格:
我有一大堆自定义设置,(到目前为止)我觉得如果我在画布中构建表格会更容易,因此我使用这种方法而不是 Tktable。
我的表格将充满只读文本小部件、可编辑文本小部件和一些下拉菜单。
这是我的问题:
1) 如何允许用户同时选择多个文本小部件并检索选择?例如,用户选择了整行/列等。
请看下面的简化代码:
package require Tk
proc makeWindow {} {
set toplevelWindow .gui
destroy $toplevelWindow
## Make the toplevel window
toplevel $toplevelWindow
wm title $toplevelWindow "Test case 1"
wm minsize $toplevelWindow 200 200
set pathName $toplevelWindow.testMultiSelection
## Create the canvas where I build the table
destroy $pathName
frame $pathName
set col 0
for {set i 0} {$i < 4} {incr i} {
set w "$pathName\_$i"
destroy $w
text $w -width 9 -height 1 -state normal
$w insert end $i
$w configure -state disabled
grid $w -row $i -column $col -sticky ew
}
grid config $toplevelWindow.testMultiSelection -column 0 -row 0 -sticky w
}
makeWindow
在上面的示例中,我希望选择一些数字(基本上类似于 ctrl+select)并以某种方式将选择存储在某处并检索它们以供以后使用。
如果上面的压缩测试用例不清楚,请告诉我。
编辑 1
忘了补充一点,我知道如何使用selection get 命令检索单个文本小部件选择。
【问题讨论】: