intractable(?) Tkinter scrollbar problem

Greg McFarlane gregm at iname.com
Mon May 31 22:43:02 EDT 1999


Hoots Mon!  What a bonny wee idea!

I think you are correct in saying that it is a problem of hysteresis,
but the hard part is finding a way to break out of the loop.

It seems that when a scrollbar is mapped, Tk temporarily shrinks the
canvas to make room for the scrollbar in the toplevel window, without
immediately changing the size of the toplevel window.  It requests a
toplevel size change and after a short time, the size of the toplevel
is changed (by the window manager?) and then Tk recomputes the sizes
of the widgets.

It looks like the cause of the loop is the time delay between Tk
requesting a toplevel size change and actually receiving it.  During
this delay the size of the canvas is smaller and so the application
thinks that the other scrollbar is now necessary.

Anyone know how to break the loop?

On 31 May, Jonathan Hogg wrote:
> In article <19990601001054.36247 at nms.otc.com.au>, Greg McFarlane
> <gregm at iname.com> wrote:
> 
> >I'm trying to perfect dynamic scrollbars (autoscrollbars) and have
> >come across a problem that I think is insoluble.  Under certain
> >circumstances, the two scrollbars are mapped and unmapped
> >continuously.
> >
> >Anyone seen this before? Or know of a workaround?
> 
> i'm not a tkinter person, but the problem you describe sounds like a
> classic case of a hysterical loop ;-). to solve it, you need to switch off
> a little after you turn on. i'll try and explain that better with an
> example: if you imagine an oven or central heating system that is trying
> to achieve a temperature of x degrees. it'll heat up to x+d degrees and
> then switch off, then gradually cool down until it's below x-d degrees
> when it will switch on again. if it switched on and off at exactly x
> degrees then it would switch on and off continuously as it hovered above
> and below x.
> 
> so to solve your problem you need to switch off your scrollbars when the
> window is resized to be a little too big rather then exactly right. then
> turn on the scrollbars when the window is a little too small.
> 
> :-j
> 
> -- 
> jonathan hogg, one good idea limited, 25 clouston street, glasgow g20 8qr, uk
> jonathan at onegoodidea.com www.onegoodidea.com t:(0)976-614338 f:(0)7970-537451
> 
> 

-- 
Greg McFarlane:    INMS Telstra Australia (gregm at iname.com)
Today's forecast:  Sunny, with occasional cloudy periods and a chance
		   of rain in some areas.




More information about the Python-list mailing list