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

I have a dialogbox which popsup from main window. How do I create scrollbars in this dialogbox?.

sub OnAbout { # Construct the DialogBox my $about = $mw->DialogBox( -title=>"About ", -buttons=>["OK"] ); $about->add('Label', -anchor => 'w', -justify => 'left', -text => qq( xxxxxx very long text xxxxxx) )->pack; $about->Show(); }
Thanks

Replies are listed 'Best First'.
Re: DialogBox and Scrollbars
by zentara (Cardinal) on Aug 18, 2011 at 13:01 UTC
    Add a Frame to the DialogBox, then pack a Scrolled Pane into the Frame, then add anything you want to the Pane.
    #!/usr/bin/perl use warnings; use strict; use Tk; use Tk::DialogBox; use Tk::Text; use Tk::Pane; my $mw = tkinit; $mw->fontCreate('big', -weight=>'bold', -size=>18); my $d = $mw->DialogBox(-buttons => ["OK", "Cancel"]); my $f = $d->add('Frame')->pack(-expand => 1, -fill => 'both'); my $p = $f->Scrolled('Pane', -scrollbars => 'osoe')->pack( -expand => 1, -fill => 'both', ); my $text = $p->Text(-bg => 'white', -font => 'big', -height => 100, )->pack; for ( 1 .. 100){ $text->insert('end', "$_\n"); } $d->Show;

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
Re: DialogBox and Scrollbars
by kcott (Archbishop) on Aug 19, 2011 at 07:11 UTC

    In the following code, I access the top Frame subwidget (advertised by Tk::DialogBox) and then use a scrolling Tk::ROText widget.

    use strict; use warnings; use Tk; use Tk::DialogBox; use Tk::ROText; my $mw = MainWindow->new(); my $d = $mw->DialogBox(); my $df = $d->Subwidget(q{top}); my $rt = $df->ScrlROText()->pack; my $content = join qq{\n} => (0 .. 100); $rt->insert(end => $content); $mw->Button(-text => q{Show}, -command => sub { $d->Show })->pack; $mw->Button(-text => q{Exit}, -command => sub { exit })->pack; MainLoop;

    I use Subwidget() for greater control. The BUGS section of Tk::DialogBox has:

    "There is no way of removing a widget once it has been added to the top Frame, unless you access the top subwidget and go through the child widgets."

    -- Ken