scrollbar "moveto" fraction computed wrong 
Author Message
 scrollbar "moveto" fraction computed wrong

Tk 8.2.1 Bug:  Generated by Scriptics' bug entry form at
Responses to this post are encouraged.

Submitted by:  John Seal
OperatingSystem:  Macintosh
OperatingSystemVersion:  Mac OS 9
Machine:  PowerCenter Pro 210
Extensions:  Tcl/Tk 8.2.1
CustomShell:  Modified Tk8.2.shlb to allow
drag-and-drop opening of script files
Synopsis:  scrollbar "moveto" fraction computed wrong

Run this script and drag the scrollbar thumbs, observing the "moveto" fraction
in relation to where you are in the scrollbar trough:

proc report {where action amount args} {
    $where configure -text [format "%s %f %s" $action $amount $args]
    $where set $amount $amount


scrollbar .vsb -orient vertical -command [list report .vmsg]
pack .vsb -side right -fill y
scrollbar .hsb -orient horizontal -command [list report .hmsg]
label .h -text "Horizontal:" -height 2 -anchor sw
label .hmsg -width 30
label .v -text "Vertical:" -height 2 -anchor sw
label .vmsg -width 30
pack .h .hmsg .v .vmsg .hsb -fill x

The Mac OS Appearance control panel allows the user to specify where the scroll
arrows appear in scrollbars: one arrow at each end (the default), both arrows at
one end only, or both arrows at both ends (my preference). Tk apparently always
computes the "moveto" fraction based on the assumption that there is one arrow
at each end. If they are both at one end, or both at both ends, you sometimes
have to drag into the scroll arrow areas in order to get to 0.0 or 1.0.

Note: If you have Mac OS set to display both arrows at both ends, you can test
this behaviour without having to change the Appearance control panel settings.
Just make the window small enough, and the extra arrows will go away. I think
the vertical scrollbar will come up this way by default; making the window
bigger will cause it to get the extra arrows, if that's your pref setting.

Also, the thumb is not proportional, even though I have set that pref, too, and
other scrollbars in other apps are pro

I expect the "moveto" fraction to reflect the thumb's position in the visible
trough, taking into account the scroll arrow preferences, and that the thumb be
proportional when the corresponding pref is set.

This is on a PowerCenter Pro 210 running Mac OS 9 with 96MB RAM and VM off

Wed, 15 May 2002 03:00:00 GMT  
 scrollbar "moveto" fraction computed wrong


> Tk 8.2.1 Bug:  Generated by Scriptics' bug entry form at

There was a dumb bug in my sample script, not germane to the problem, but
it does keep the thumb from following the mouse as you drag. I was sending
the "set" back to the message display, not the scrollbar. Try this script:

proc report {where action amount args} {
    ${where}msg configure -text [format "%s %f %s" $action $amount $args]
    ${where}sb set $amount $amount


scrollbar .vsb -orient vertical -command [list report .v]
pack .vsb -side right -fill y
scrollbar .hsb -orient horizontal -command [list report .h]
label .h -text "Horizontal:" -height 2 -anchor sw
label .hmsg -width 30
label .v -text "Vertical:" -height 2 -anchor sw
label .vmsg -width 30
button .half -text "Set Halfway" -command [list .hsb set .5 .5]
pack .h .hmsg .v .vmsg .half .hsb -fill x

Now that the thumb moves, you can see the problem very clearly. Do this:

-Set the Appearance control panel to put both arrows at one end.
-Run the sample script.
-Drag the thumb of the horizontal scrollbar to the far right end.
-Click on the thumb, and it immediately jumps to the left by 1 arrow width.

I'm guessing that this behavior is caused by computing the fractional
position of the thumb based on the assumed placement of the arrows one at
each end, rather than whatever the actual placement happens to be.

John Seal

Wed, 15 May 2002 03:00:00 GMT  
 [ 2 post ] 

 Relevant Pages 

1. Characters "?", "?", "ΓΌ" shown in wrong font

2. Problem "bad option delta" with Scrollbar

3. Scrollbar information with the "get" command

4. the "new computing model"

5. "High School Computing: The Inside Story"


7. string.join(["Tk 4.2p2", "Python 1.4", "Win32", "free"], "for")

8. new book "Advanced Scientific Computing"

9. wrong "clock" calculation

10. .button "configure" returns wrong information

11. What is wrong here with "exec"

12. bad geometry "+0+0": whats wrong?


Powered by phpBB® Forum Software