2011-09-07 44 views
1

我有一个问题,滚动条被制成似乎在左边,我试过很多组合,以便将其移动到右侧。Tk GUI滚动条

我的代码如下所示:

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,所以当然它会出现在左边。你需要把它放在一个列数比要放置在画布列更大。

当你刚开始学习如何做使用网格几何管理器,它真的帮助,如果你实际绘制的图形用户界面在一张方格纸上。这样做可以清楚地了解每个小部件所在的列,以及是否需要跨越其他行或列。

+0

非常感谢.... – mayank