Oberbee has asked for the wisdom of the Perl Monks concerning the following question:

Great Omniscient Masters,

I am attempting to create a table of items with a uniform height inside an ROText widget. When attempting to use windowCreate to insert a scrollable ROText description I get this error:

unknown option "-scrollbars" at ...

Here is the code in question:

$row0p0 = $top->Label(-text => $cat1, -height =>7, -width => 15, -relief => 'sunken')->grid( $row0p1 = $top->Label(-text => $lb12,-height =>7, -width => 15, -relief => 'sunken'), $row0p2 = $top->ROText(-height =>8, -width => 22, -wrap => 'word', -sc +rollbars => 'oe'), $row0p3 = $top->Button(-text => "Photo"), $row0p4 = $top->Button(-text => "Link")); $row0p2->insert('end', " [long description] "); $top->windowCreate('end', -window => $row0p0); $top->windowCreate('end', -window => $row0p1); $top->windowCreate('end', -window => $row0p2); $top->windowCreate('end', -window => $row0p3); $top->windowCreate('end', -window => $row0p4);

How can I make this ROText widget scrollable?

Replies are listed 'Best First'.
Re: -scrollbars is unknown option in windowCreate
by AnomalousMonk (Archbishop) on Jul 15, 2018 at 17:47 UTC

    Assuming Perl/Tk, see Tk::Scrolled.

    c:\@Work\Perl\monks>perl -wMstrict -le "use Tk; use Tk::ROText; ;; my $MW = tkinit; ;; my $row0p2 = $MW->Scrolled('ROText', -scrollbars => 'oe', qw(-height 8 -width 22 -wrap word), )->pack; ;; $row0p2->insert('end', '[ ' . 'long description ' x 80 . ']'); ;; MainLoop; "


    Give a man a fish:  <%-{-{-{-<

Re: -scrollbars is unknown option in windowCreate
by Marshall (Canon) on Jul 15, 2018 at 17:42 UTC
    I am not sure what graphic package you are using? It's been some years since I did graphical UI using Tk code with Perl. However my perhaps not good memory may help... not sure. I remember that scrollable is a property of a frame, not the object within the frame. In general, create a window, create a frame within that window, create objects within that frame. An attribute like "scrollable" would apply to the frame - the ability to show portions of the object - the object itself would not know or care how much of it is displayed.
Re: -scrollbars is unknown option in windowCreate
by zentara (Cardinal) on Jul 16, 2018 at 10:01 UTC
    How can I make this ROText widget scrollable?

    As was said above, use the Scrolled widget.

    #!/usr/bin/perl use strict; use Tk; use Tk::ROText; my $file = shift || $0; open (FH,"< $file") or die "$!\n"; my @lines = <FH>; close FH; my $main = MainWindow->new; my $text = $main->Scrolled('ROText', -width => 80, -height => 30, -bg=>'black', -fg=>'lightyellow', -scrollbars => 'osow', ) ->pack(); foreach my $line (@lines){ $text->insert('end',$line); $text->update; } $main->Button(-text => 'Cancel', -command => sub{exit} )->pack; MainLoop;

    I'm not really a human, but I play one on earth. ..... an animated JAPH
Re: -scrollbars is unknown option in windowCreate
by Oberbee (Novice) on Jul 15, 2018 at 18:01 UTC

    I have specified 'use Tk' and 'require Tk::ROText'.

    $row0p2 = $top->ROText(-height =>8, -width => 22, -wrap => 'word', -scrollbars => 'oe')->pack;

    will produce a widget with working scrollbars. It is just when I try to insert new text widget into another with windowCreate I get the error.

      $row0p2 = $top->ROText(-height =>8, -width => 22, -wrap => 'word',
      -scrollbars => 'oe')->pack;

      will produce a widget with working scrollbars.

      I don't have the latest version of Tk (804.034) and my Tk::ROText does not support the  -scrollbars option, so I'm afraid I can't help further with windowCreate.

      c:\@Work\Perl\monks>perl -wMstrict -le "use Tk; use Tk::ROText; ;; print 'Perl/Tk version: ', $Tk::VERSION; ;; my $MW = tkinit; ;; my $row0p2 = $MW->ROText(-height =>8, -width => 22, -wrap => 'word', -scrollbars => 'oe')->pack; ;; $row0p2->insert('end', '[ ' . 'long description ' x 80 . ']'); ;; MainLoop; " Perl/Tk version: 804.03 Tk::Error: Can't set -scrollbars to `oe' for Tk::ROText=HASH(0x285580c +): Bad option `-scrollbars' at C:/strawberry/5.14/perl/site/lib/Tk/Configure.pm line 45. at C:/strawberry/5.14/perl/site/lib/Tk/Derived.pm line 294. Tk callback for event Tk callback for . Tk callback for .rotext Tk::Derived::configure at C:/strawberry/5.14/perl/site/lib/Tk/Derived +.pm line 306 Tk::Widget::new at C:/strawberry/5.14/perl/site/lib/Tk/Widget.pm line + 205 Tk::Widget::__ANON__ at C:/strawberry/5.14/perl/site/lib/Tk/Widget.pm + line 256 Can't set -scrollbars to `oe' for Tk::ROText=HASH(0x285580c): Bad opti +on `-scrollbars' at C:/strawberry/5.14/perl/site/lib/Tk/Configure.pm +line 45. at C:/strawberry/5.14/perl/site/lib/Tk/Derived.pm line 294. at C:/strawberry/5.14/perl/site/lib/Tk/Derived.pm line 306.


      Give a man a fish:  <%-{-{-{-<

      I have found an acceptable workaround for the problem. By using Tk::Pane the entire main window is scrollable and the scrollbars inside the ROText widget are still functional. The downside is that the widgets at the top of my window also scroll out of view. Since the main focus of the window is the long list of items I can live with this.

      #! /usr/bin/perl -w use Tk; use Tk::Pane; require Tk::ROText; my $mw = MainWindow->new; $pane = $mw->Scrolled(Pane, -scrollbars => 'ow', -sticky => 'nswe', -gridded => 'y', -height => '800' ); $pane->Frame(); $pane->grid; $pos1 = $pane->ROText(-height => 7, -width => 20, -wrap => 'word')->gr +id ( $pos2 = $pane->ROText(-height => 7, -width => 20, -wrap => 'word +'), $pos3 = $pane->Scrolled('ROText', -height =>7, -width => 20, -wrap + => 'word', -scrollbars => 'oe'), $pane->Label(-height => 100, -width => 100,-text => "Photo" ), $pane->Button(-text => "Link"), -sticky => "nsew"); $pos1->tagConfigure('bold', -font => "Courier 10 bold", -justify => " +center", -spacing1 => 50); $pos2->tagConfigure('bold', -font => "Courier 10 bold", -justify => " +center", -spacing1 => 30); $pos1->insert('end', "Evening Gown", 'bold'); $pos2->insert('end', "Blue and black formal dress", 'bold'); $pos3->insert('end', " [Long description] "); MainLoop;