Greetings fellow monks,

A few days ago someone in the chatterbox gave a link to this site, which is a kind of word-association puzzle.

After trying it out, and getting hooked (it's addicting!), I decided to write a little Windows Perl/Tk GUI to help me cheat search for potential words. 8~D

When I created a Scrolled "ROText" widget, I realized there was an apparent bug which I have seen recently in other Perl/TK applications:

my $t = $w->Scrolled('ROText', '-bg', '#ffdfff', '-scrollbars', 'o +soe');

The above line is supposed to create a Scrolled Read-only Text (ROText) widget, with a lilac background color (0xffdfff), and optional 'South' and 'East' scrollbars.   When the widget is first filled with text, though, even if the "East" (right-side) scrollbar appears, the slider bar does not appear.

After resizing the whole GUI, however, the ROText window is resized, causing the scrollbar slider to appear as it should have done.  Another way to make the slider "pop into view" is to click the left mouse inside the ROText window, and move the mouse outside of the window (still holding the button down).

I've done some searching, both inside and outside of Perlmonks, for anyone with a similar problem, but haven't found anything that seems to address the issue.

Has anyone else seen this bug?

I have found that I can get around the problem by doing a $t->see("1.0"), followed by a $t->update(), before trying to see the end of the text window.

Here is a stripped-down version of the entire program.  To demonstrate the problem, type a valid address into the Entry widget marked "HTTP Address", and then type <Return>, or click the button marked "Load".  To demonstrate the workaround, select the Checkbutton marked "Workaround" first; leave it unselected to see the bug (in Windows):

#!/usr/bin/perl # # Example of an apparent Windows Perl/Tk bug in ROText & Text. # 061028 -- liverpole # # Strict use strict; use warnings; # Libraries use HTML::TreeBuilder; use LWP::Simple; use Tk; use Tk::Canvas; use Tk::ROText; # Globals my $workaround = 0; my $http_url = ""; # ============================================================= # Main Program -- create the GUI # ============================================================= # my $mw = new MainWindow(-title=>'Bug in Win32 Perl/Tk??'); my $f1 = $mw->Frame->pack(-expand => 0, -fill => 'x'); my $f2 = $mw->Frame->pack(-expand => 1, -fill => 'both'); my $b0 = $f1->Button( -bg => "green", -text => "Exit (Escape)", -command => sub { $mw->destroy } )->pack(-side => 'right'); my $pout = rotext($f2); my $f3 = $f1->Frame->pack(-side => 'left', -fill => 'none'); my $c1 = $f3->Checkbutton(-text => "Workaround", -variable => \$work +around) ->pack(-side => 'left'); my $l1 = $f3->Label(-text => " HTTP Address") ->pack(-side => 'left', -expand => 0, -fill => 'y'); my $e1 = $f3->Entry(-width => 64, -textvar => \$http_url) ->pack(-side => 'left', -expand => 0, -fill => 'y'); my $b1 = $f1->Button( -bg => "green", -text => "Load (Return)", -command => sub { load_url($http_url, $pout) } )->pack(-side => "left"); $mw->bind("<Escape>" => sub { $b0->invoke() }); $mw->bind("<Return>" => sub { $b1->invoke() }); $e1->focus(); MainLoop; # ============================================================ # Subroutines # ============================================================ sub load_url { my ($url, $pout) = @_; $pout->(); ($url || 0) or return; ($url =~ m|^http://i|) or $url = "http://$url"; my $content = get($url); my $font = "arial 10"; if (!defined($content)) { $pout->("Unable to load address '$url'", "$font bold", "red"); return; } $pout->($content); } sub rotext { my ($w) = @_; my $t = $w->Scrolled('ROText', '-bg', '#ffdfff', '-scrollbars', 'o +soe'); $t->pack(qw(-side top -expand 1 -fill both)); my $tag = 0; my $psub = sub { my ($text, $font, $color) = @_; ($text || 0) or $t->delete("1.0", "end"); ($text || 0) and $t->insert("end", "$text\n", ++$tag); ($font || 0) and $t->tagConfigure($tag, -font => $font) +; ($color || 0) and $t->tagConfigure($tag, -background => $color +); if ($workaround) { $t->see("1.0"); $t->toplevel->update(); } $t->see("end"); $t->toplevel->update(); }; return $psub; }

Can anyone tell me whether this is a known bug?  And, is there a better workaround than the one I've implemented above?  The bug also happens with a regular Scrolled "Text" window, but I'd be very interested if anyone knows what other conditions make it happen.

For the record, I am using ActiveState Perl, version 5.8.7, binary build 815 [211909], built on November 2, 2005.

Update:  Added <readmore> tags.


s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/

In reply to Bug in Win32 Perl/Tk Scrolled ROText widget with optional scrollbars 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.