首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何为TCL Tk禁用Tk表中的完整列

如何为TCL Tk禁用Tk表中的完整列
EN

Stack Overflow用户
提问于 2012-09-25 22:33:58
回答 2查看 1.6K关注 0票数 1

我是TCL Tk的新手,我正在使用Tk表在我的GUI中创建一个表。

代码语言:javascript
复制
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列。谁能告诉我怎么才能做到这一点。我很久以前就开始尝试这个了。请帮帮我。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-09-26 04:20:21

Tk没有内置的表格小部件,所以我假设你使用的是here的Tktable/Tile。

下面是我将禁用其中2列的示例放在一起。基本上,您可以使用-coltagcommand和一个函数将您想要编辑的所有条目分配给某个标记,然后将状态等属性应用于该标记。

代码语言:javascript
复制
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
票数 1
EN

Stack Overflow用户

发布于 2014-01-23 16:18:51

您还可以使用-titlerows 'n'-titlecols 'm'中的任何选项来声明前'n‘行是只读标题,或者前'm’行是只读标题。

希望我能帮上忙

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12585241

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档