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
请帮我解决这个问题..
谢谢
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 -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
Please help me with this..
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你把它放在第 0 列,所以它当然会出现在左边。您需要将其放在比要放置画布的列大的列号中。
当您刚刚学习如何使用网格几何管理器时,如果您实际绘制GUI 绘制在一张方格纸上。这样做可以清楚地表明每个小部件位于哪一列,以及它们是否需要跨越额外的行或列。
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.