开发者

Tk GUI Scrollbar

I've a problem that the scrollbar being made appears to be in the left, i've tried many combinations so as to move it to the right.

My code looks like this:

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 -f开发者_JS百科ill 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

Please help me with this..

Thanks


You are putting it in column 0, so of course it will appear on the left. You need to put it in a column number greater than the column that you are placing the canvas in.

When you are just learning how to do use the grid geometry manager, it really helps if you actually draw the GUI out on a piece of graph paper. Doing that makes it crystal clear which column each widget goes in, and whether or not they need to span additional rows or columns.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜