Tcl 如何在不编辑状态下选择Tktable中的单元格?

Tcl 如何在不编辑状态下选择Tktable中的单元格?,tcl,tk,Tcl,Tk,我正在使用Tktable包绘制表格,如下示例: package require Tktable global TableValue array set TableValue { 0,1 Col1 0,2 Col2 1,0 Row1 2,0 Row2 1,1 a 1,2 b 2,1 c 2,2 d } table .t -rows 3 -cols 3 -titlerows 1 -titlecols 1 -variable TableValue pack .t 单击单元格时,如何仅显示单

我正在使用Tktable包绘制表格,如下示例:

package require Tktable
global TableValue
array set TableValue {
    0,1 Col1 0,2 Col2 1,0 Row1 2,0 Row2 1,1 a 1,2 b 2,1 c 2,2 d 
}
table .t -rows 3 -cols 3 -titlerows 1 -titlecols 1 -variable TableValue
pack .t

单击单元格时,如何仅显示单元格的选定状态而不是编辑状态,我可以使用“删除”清除单元格内容,如果双击单元格,则显示编辑状态。如何认识到这一点?谢谢

在表小部件中嵌入小部件可能是使用表小部件可以实现的最大视觉控制。这是因为该表具有难以覆盖到您的规范的默认绑定。但是您可以插入如下所示的小部件,并完全控制它们的外观。随意使用属性和绑定。但这应该是一个公平的开始

package require Tktable

array set TableTitles {
    0,1 Col1 0,2 Col2 1,0 Row1 2,0 Row2, 1,1 a 1,2 b 2,1 c 2,2 d
}


table .t -rows 3 -cols 3 -titlerows 1 -titlecols 1 -variable TableTitles
pack .t

proc EnableEntry { entry } {
    $entry configure -state normal -cursor ibeam
    $entry selection range 0 end
}

foreach row [list 1 2] {
    foreach col [list 1 2] {
        set cell [set row],[set col]
        # Use the array already created for the entry variable
        set entry [entry .t.e$row$col -justify center -textvariable TableTitles($cell) \
            -highlightthickness 1 -highlightcolor blue -state disabled \
            -disabledbackground white -disabledforeground black -cursor arrow]

        bind $entry <Double-Button-1> "EnableEntry $entry"
        bind $entry <Button-1> "focus $entry"
        bind $entry <FocusOut> "$entry configure -state disabled -cursor arrow"
        .t window configure $cell -window $entry
    }
}
包需要Tktable
数组集表格标题{
0,1列1 0,2列2 1,0行1 2,0行2,1,1 a 1,2 b 2,1 c 2,2 d
}
表t-第3行-第3列-标题栏1-标题栏1-可变表格标题
背包
proc EnableEntry{entry}{
$entry配置-状态正常-光标ibeam
$entry选择范围0结束
}
每行[列表1和2]{
foreach col[列表1和列表2]{
设置单元格[设置行],[设置列]
#使用已为entry变量创建的数组
设置条目[entry.t.e$行$列-居中对齐-文本变量表格标题($单元格)\
-highlightthickness 1-highlightcolor蓝色-状态已禁用\
-禁用背景白色-禁用背景黑色-光标箭头]
绑定$entry“启用条目$entry”
绑定$entry“焦点$entry”
绑定$entry“$entry配置-状态禁用-光标箭头”
.t窗口配置$cell-窗口$entry
}
}

非常感谢您详尽的解释。