我是TCL Tk的新手,我正在使用Tk表在我的GUI中创建一个表。
Basically it contains some hardware register's info like its name, address, value....etc.
Now i want that user should not be able to change the register address and name and hence i 想要完全关闭Tk表的name和address列。谁能告诉我怎么才能做到这一点。我很久以前就开始尝试这个了。请帮帮我。
发布于 2012-09-26 04:20:21
Tk没有内置的表格小部件,所以我假设你使用的是here的Tktable/Tile。
下面是我将禁用其中2列的示例放在一起。基本上,您可以使用-coltagcommand和一个函数将您想要编辑的所有条目分配给某个标记,然后将状态等属性应用于该标记。
package require Tktable
array set cells {
0,0 David 0,1 "1234 Fake st" 0,2 foo
1,0 John 1,1 "444 New York Ave" 1,2 bar
}
# This function returns the tag to assign to all cells in col $col
proc tagCol col {
# If we're name or address column, add the disabledColumn tag to it
if {$col == 0 || $col == 1} {
return disabledColumn;
}
}
table .mytable -rows 2 -cols 3 -variable cells -coltagcommand tagCol
# Disable editing of the disabled column entries
.mytable tag config disabledColumn -state disabled -fg blue
pack .mytable发布于 2014-01-23 16:18:51
您还可以使用-titlerows 'n'和-titlecols 'm'中的任何选项来声明前'n‘行是只读标题,或者前'm’行是只读标题。
希望我能帮上忙
https://stackoverflow.com/questions/12585241
复制相似问题