如何在 tcl/tk 中手动滚动小部件滚动深度?

问题描述 投票:0回答:0

有谁知道我怎样才能手动给“滚动”深度而不是使用“yview”?

例子:

pack [frame .top.frm -bg #efefef] -side left -anchor nw

set dir $env(HOME)
set total [llength [glob -nocomplain -directory $dir -tails *]]

pack [scrollbar .top.frm.sbr -orient vertical -command ".top.frm.txt $total"] -side right -fill y
pack [text .top.frm.txt -bg #efefef -yscrollcommand ".top.frm.sbr set" -wrap word] -side left -anchor nw -fill both -expand true -padx 0 -pady 0

...

.top.frm.txt window create end -window $panel

bind .top.frm.txt <Configure> {
    %W.pnl configure -width [expr {%w - 5}] -height [expr {%h - 5}]
}

pack propagate $panel 0

我不想使用“yview”,而是想传递一个变量(在本例中是 - $total),其中包含要计算的元素总数,以便滚动在垂直方向上提供适当的移动深度。


之前:

pack [scrollbar .top.frm.sbr -orient vertical -command ".top.frm.txt yview"]

之后:

pack [scrollbar .top.frm.sbr -orient vertical -command ".top.frm.txt $total"]

我问是因为我无法通过搜索互联网找到解决方案。

tcl scrollbar tk-toolkit
© www.soinside.com 2019 - 2024. All rights reserved.