Having tried this out, I could offer an alternative point of view: the problem is not so much with the Tk scrollbar behavior, but is rather due to an interaction between how the scrollbars work and the kind of text data you are loading into the scrolled widget.

If you add this line to the "load_url" sub, the widget behavior will be more "normal":

$text =~ s/>/>\n/g; # add this right after "my $text = $tree->as_ +HTML()"
The point is that the scrollbar slider's size is based on line count and the number of lines visible in the scrolled widget at a given moment, as well as the total percentage of text visible (or something to that effect).

If the number of text lines (i.e. the number of substrings conjoined by explicit line-feed characters) is less than the height of the Tk::Text window, but the lines are really long and get wrapped beyond the height of the window, you have a situation where the slider-sizing logic (and possibly other aspects of scrollbar behavior) will likely run into boundary conditions, or situations where "reasonable defaults" are at best much more difficult to establish and implement.

I think the exact behavior of OP code may depend on whether the html data contains any line-feeds as text content, but I'm not sure about that, just as I'm not sure yet what HTML::TreeBuilder's "as_HTML()" method does to web-page data in terms of preserving or removing line-feed characters. (Maybe that'll be explained in the docs; I just haven't looked yet.)

So, if you simply take one or two simple measures to provide a sensible concession to human readability, things will go better, because the widgets seem to have been designed with some built-in assumptions about that sort of thing.


In reply to Re: Very strange Scrollbar behavior in Win32 Perl/Tk version 804.027 by graff
in thread Very strange Scrollbar behavior in Win32 Perl/Tk version 804.027 by liverpole

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.