2017-11-16 1 views
0

:상태를 편집하지 않고 Tktable에서 셀을 선택하는 방법은 무엇입니까? 내가 예를 아래의 표를 그립니다 Tktable 패키지를 사용하고

package require Tktable 
global TableValue 
array set TableValue { 
    0,1 Col1 0,2 Col2 1,0 Row1 2,0 Row2 1,1 a 1,2 b 2,1 c 2,2 d 
} 
table .t -rows 3 -cols 3 -titlerows 1 -titlecols 1 -variable TableValue 
pack .t 

내가 셀을 클릭하면, 다만 상태가 내가 취소 "삭제"를 사용할 수있는 상태를 편집하지 선택한 셀을 표시하는 방법 셀 내용 및 셀을 두 번 클릭하면 편집 상태가 표시됩니다. 그걸 깨닫는 방법? 감사!

답변

0

표 위젯으로 달성 할 수있는 가장 큰 시각적 제어는 아마도 위젯을 표에 포함 시켜서 수행 할 수 있습니다. 이는 테이블에 사용자의 사양에 우선 적용하기 어려운 기본 바인딩이 있기 때문입니다. 하지만 수 있습니다 아래 삽화와 같은 위젯을 삽입하고 완전히 모양을 제어 할 수 있습니다. 원하는대로 특성 및 바인딩을 가지고 놀 수 있습니다. 그러나 이것은 공정한 시작이어야합니다.

package require Tktable 

array set TableTitles { 
    0,1 Col1 0,2 Col2 1,0 Row1 2,0 Row2, 1,1 a 1,2 b 2,1 c 2,2 d 
} 


table .t -rows 3 -cols 3 -titlerows 1 -titlecols 1 -variable TableTitles 
pack .t 

proc EnableEntry { entry } { 
    $entry configure -state normal -cursor ibeam 
    $entry selection range 0 end 
} 

foreach row [list 1 2] { 
    foreach col [list 1 2] { 
     set cell [set row],[set col] 
     # Use the array already created for the entry variable 
     set entry [entry .t.e$row$col -justify center -textvariable TableTitles($cell) \ 
      -highlightthickness 1 -highlightcolor blue -state disabled \ 
      -disabledbackground white -disabledforeground black -cursor arrow] 

     bind $entry <Double-Button-1> "EnableEntry $entry" 
     bind $entry <Button-1> "focus $entry" 
     bind $entry <FocusOut> "$entry configure -state disabled -cursor arrow" 
     .t window configure $cell -window $entry 
    } 
} 
+0

대단히 감사드립니다. – Jimmy

관련 문제