如何使用Tktable包实现样本结果,将组合框添加到单元格中?或者是否还有其他可用于实现方便的软件包?谢谢! sample
答案 0 :(得分:0)
您应首先尝试自己执行某些操作,然后发布您尝试过的内容,并在遇到困难时询问具体问题。只需阅读文档就可以得到这样的东西。
package require Tktable
package require Ttk
pack [table .t -cols 5 -rows 5 -variable tabarray]
set cb [ttk::combobox .t.cb]
array set tabarray [list 1,0 1 2,0 2 3,0 3 4,0 4]
array set tabarray [list 0,1 "Layer Name" 0,2 Transmission 0,3 Phase 0,4 Nested]
.t window config 1,1 -window $cb -sticky news
或者如果你想在不使用tktable的情况下完成同样的操作,你可以利用Tk附带的网格几何体。但是你可能最好不要使用该表,因为它为你管理几何,提供列和行扩展等。
package require Ttk
set coltitles {"Layer Name" "Transmission" "Phase" "Nested"}
# Frame to hold the 'cells'
grid [frame .f] -row 0 -column 0 -sticky news
grid columnconfigure .f {1 2 3 4} -weight 1 -uniform 1
# Row numbers
for {set row 1} {$row < 5} {incr row} {
# Row labels
grid [label .f.tr$row -text $row -anchor e -relief groove -bd 1 -width 2] -row $row -column 0 -sticky news
}
# Column titles
for {set col 1} {$col < 5} {incr col} {
grid [label .f.tc$col -text [lindex $coltitles [expr $col - 1]] -anchor c -relief groove -bd 1] -row 0 -column $col -sticky news
}
# The table cells
grid [ttk::combobox .f.cb] -row 1 -column 1 -sticky news
for {set row 1} {$row < 5} {incr row} {
for {set col 1} {$col < 5} {incr col} {
# Cell 1,1 already has the combobox. Skip it.
if {($row == 1) && ($col == 1)} continue
set id r[set row]c[set col]
grid [entry .f.$id -relief groove -bd 1] -row $row -column $col -sticky news
}
}