1

私は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 テーブルの名前とアドレスの列を完全に無効にしたい。どうすればこれができるか教えてもらえますか。私は長い間これを試しています。私を助けてください 。

4

2 に答える 2

1

Tk doesn't have a built in table widget, so I assume you're using the Tktable/Tile from here.

Here is an example I threw together that disabled 2 of the columns. Basically you assign all of the entries that you want to edit with a certain tag by using -coltagcommand and a function, then you apply attributes like state to that tag.

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
于 2012-09-25T20:20:20.750 に答える