2011-09-07 2 views
1

스크롤 막대가 왼쪽에있는 것처럼 보였습니다. 오른쪽으로 이동하기 위해 여러 조합을 시도했습니다.Tk GUI Scrollbar

내 코드는 다음과 같습니다

set dataSheetFrame($k) [frame $curPath($k).frame1 -height 420 -relief groove] 
#pack $dataSheetFrame($k) 
scrollbar $dataSheetFrame($k).vscroll1 -highlightthickness 0 -orient vertical \ 
     -width 15 
set viewC1($k) [canvas $dataSheetFrame($k).canvas -height $cHeight1 -width $cWidth1 \ 
     -yscrollcommand "$dataSheetFrame($k).vscroll1 set" \ 
     -scrollregion "0 0 $cWidth1 $cHeight1" -bg black] 
grid $dataSheetFrame($k).vscroll1 -in $dataSheetFrame($k) -row 0 -column 0 \ 
     -rowspan 1 -columnspan 1 -sticky news 
grid $viewC1($k) -in $dataSheetFrame($k) -row 0 -column 1 \ 
     -rowspan 1 -columnspan 1 -sticky news 
grid rowconfigure $dataSheetFrame($k) 0 -weight 1 -minsize 0 
grid columnconfigure $dataSheetFrame($k) 0 -weight 1 -minsize 0 
$viewC1($k) create line $cellWidth 0 $cellWidth $cHeight1 -width 3 -fill white 
$viewC1($k) create line [expr $cellWidth + $dWidth] 0 \ 
     [expr $cellWidth + $dWidth] $cHeight1 -width 1 -fill white 
$viewC1($k) create line [expr $cellWidth + 2 * $dWidth] 0 \ 
     [expr $cellWidth + 2 * $dWidth] $cHeight1 -width 1 -fill white 

for {set i 0} {$i < [llength $cfgNames]} {incr i} { 
    set name [lindex $cfgNames $i] 
    $viewC1($k) create text [expr $cellWidth/2] \ 
      [expr $offsety + $i * 30 ] -anchor center -width 0 \ 
      -text $name -justify center -fill white 
    set j 1 
    foreach process {Slow Typical Fast} { 
     set y [expr $offsety + $i * 30 ] 
     if {[info exists tpfValues($name,$process)]} { 
      $viewC1($k) create text [expr $cellWidth + \ 
        $j * $dWidth - $dWidth/2] $y \ 
        -anchor center -width 0 -fill white \ 
        -text $tpfValues($name,$process) \ 
        -justify center 
     } 
     $viewC1($k) create line 0 [expr $y + 15] $cWidth1 \ 
       [expr $y + 15] -width 3 -fill white 
     incr j 
    } 
} 

set offsetTpf [llength $cfgNames] 

for {set i 0} {$i < [llength $tpfNames]} {incr i} { 
    set name [lindex $tpfNames $i] 
    $viewC1($k) create text [expr $cellWidth/2] \ 
      [expr $offsety + $offsetTpf * 30 ] -anchor center -width 0 \ 
      -text $name -justify center -fill white 
    set j 1 
    foreach process {Slow Typical Fast} { 
     set y [expr $offsety + $offsetTpf * 30 ] 
     if {[info exists tpfValues($name,$process)]} { 
      $viewC1($k) create text [expr $cellWidth + \ 
        $j * $dWidth - $dWidth/2] $y \ 
        -anchor center -width 0 -fill white \ 
        -text $tpfValues($name,$process) \ 
        -justify center 
     } 
     $viewC1($k) create line 0 [expr $y + 15] $cWidth1 \ 
       [expr $y + 15] -width 3 -fill white 
     incr j 
    } 
    incr offsetTpf 
} 
$dataSheetFrame($k).vscroll1 configure -command "$viewC1($k) yview" 
pack $dataSheetFrame($k) -side left 

이 저를 도와주세요 ..

감사

+0

문제를 격리하고보다 압축 된 코드 목록을 제공해야합니다. 이것은 우리뿐만 아니라 당신을 위해서도 좋을 것입니다. – mouviciel

답변

3

물론이 왼쪽에 나타납니다, 그래서 당신은 열 0에 넣어된다 . 당신은 당신의 캔버스를 배치하는 열보다 더 큰 열 번호에 넣어해야합니다.

방금 ​​그리드 형상 관리자를 사용하는 방법을 학습하는 경우, 실제로 GUI를 그리는 경우가 정말 도움이 그래프 용지 한 장에. 이렇게하면 각 위젯이 어느 열에 들어가는 지 명확하게 알 수 있고 추가 행이나 열을 확장해야하는지 여부가 명확 해집니다.

+0

고마워요. .... – mayank