2017-10-10 8 views

답변

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 
    } 
} 
+0

"-create"를 사용하는 데 실수를했습니다. 대단히 감사합니다. "-window"여야합니다. 나는 더 조심스럽게 문서를 읽어야한다 ... 다시 한 번 감사드립니다! – Jimmy