无论何时在tcl中选择表列表中的项目,都可以使用该命令?

无论何时在tcl中选择表列表中的项目,都可以使用该命令?,tcl,Tcl,我有一个表格列表,我想在某处显示当前所选项目的信息。就像synaptic的(图) 这是我的列表: tablelist::tablelist .t.frm.lbf.mlb -selectmode multiple -columns {0 "File" 0 "Name" 0 "Version" 0 "Archtectures" 0 "Summary" 0 "Type"} \ -stretch all -background white -width 57 -xscroll {.t.frm.lbf.h

我有一个表格列表,我想在某处显示当前所选项目的信息。就像synaptic的(图)

这是我的列表:

tablelist::tablelist .t.frm.lbf.mlb -selectmode multiple -columns {0 "File" 0 "Name" 0 "Version" 0 "Archtectures" 0 "Summary" 0 "Type"} \
-stretch all -background white -width 57 -xscroll {.t.frm.lbf.h set} -yscroll {.t.frm.lbf.v set}  -showseparators true
因此,每当单击(选中)一行时,它都会显示信息


我找不到如何将命令绑定到项目单击(选择)。

正如我在评论中提到的,当在tablelist正文中单击时,您可以使用绑定
[.tbl bodytag]
来触发函数。例如:

bind [.t.frm.lbf.mlb bodytag] <Button-1> {
    lassign [tablelist::convEventFields %W %x %y] w x y
    lassign [split [$w containingcell $x $y] ,] row col
    tk_messageBox -title Info -message "This is $row,$col"
}
这将为您获取值
openoffice.org calc
,然后您可以使用该值来获取希望在不同小部件中显示的任何信息

[.t.frm.lbf.mlb row配置$row-text]
提供行
$row
中的所有文本设置

[lindex[.t.frm.lbf.mlb rowconfigure$row-text]4]
仅在tcl列表中给出该行的文本值


[lindex[lindex[.t.frm.lbf.mlb rowconfigure$row-text]4]2]
然后给出第三列(索引2)中的文本值。

将脚本绑定到tablelist小部件的
虚拟事件,并在事件处理程序中使用
.tablelist curselection
检索所选索引。请确保为列指定-name属性,以便在用户更改列顺序的情况下也可以轻松寻址单元格:

.t.frm.lbf.mlb columnconfigure 0 -name file

bind .t.frm.lbf.mlb <<TablelistSelect>> [list packageSelected %W]

proc packageSelected {w} {
    # -selecttype row is the default
    foreach row [$w curselection] {
        puts [format "Package file %s selected" [$w getcells $row,file]]
    }
}
.t.frm.lbf.mlb列配置0-名称文件
bind.t.frm.lbf.mlb[选择的列表包%W]
proc packageSelected{w}{
#-selecttype行是默认值
每行[$w]{
将[格式化“选定的包文件%s”[$w getcells$行,文件]]
}
}

我现在无法测试它,但您可以研究一下,尤其是
bind[.tbl bodytag]{…}
然后您可以在这里定义您的命令,或者创建一个
proc
,它将被此绑定调用。
.t.frm.lbf.mlb columnconfigure 0 -name file

bind .t.frm.lbf.mlb <<TablelistSelect>> [list packageSelected %W]

proc packageSelected {w} {
    # -selecttype row is the default
    foreach row [$w curselection] {
        puts [format "Package file %s selected" [$w getcells $row,file]]
    }
}