in reply to Re: How to set the MainWindow agile to the context in Perl/Tk
in thread How to set the MainWindow agile to the context in Perl/Tk

Thank you Ken.

I'm using TK::NoteBook and wonder if I could add the 'scroll' feature in each tab window to resolve the missing items dealing with monitor resolution issue but is that a limitation to add 'scroll' feature in TK::NoteBoot? Or I have misread that? Thank you.

  • Comment on Re^2: How to set the MainWindow agile to the context in Perl/Tk

Replies are listed 'Best First'.
Re^3: How to set the MainWindow agile to the context in Perl/Tk
by kcott (Archbishop) on May 18, 2015 at 07:48 UTC
    "... wonder if I could add the 'scroll' feature ..."

    Tk::Scrolled explains how to do that.

    It sounds like your application is very similar (at least in terms of GUI layout) to one I wrote quite a few years ago and which I run (without any problems) fairly regularly. I put the entire Tk::NoteBook in a scrolled Tk::Pane.

    Here's a severely cutdown version of just the relevant code:

    my $mw = MainWindow->new(); ... build_main_pane(\$mw); ... sub build_main_pane { my $mw = ${+shift}; my $mp = $mw->Scrolled(q{Pane}, -scrollbars => q{osoe}, -sticky => q{nsew}, ); $mp->pack(-fill => q{both}, -expand => 1); build_notebook($mp); return; } sub build_notebook { my ($parent) = @_; my $nb = $parent->NoteBook(); $nb->pack(-fill => q{both}, -expand => 1); build_pages($nb); return; } sub build_pages { my ($nb) = @_; build_example_page($nb); build_other_page($nb); ... build_last_page($nb); return; } sub build_example_page { my ($nb) = @_; my $example_page = $nb->add(example_page => -label => 'Example Page', ... ); ... }

    -- Ken

      Thanks a bunch Ken. This piece of code really help. I know what I should do now. I'm applying your sample code in my script. Big thanks! :)

Re^3: How to set the MainWindow agile to the context in Perl/Tk
by Anonymous Monk on May 18, 2015 at 08:35 UTC

    Tips Re: Tk::Notebook - Scrolling Tabs (diy)

    Example

    #!/usr/bin/perl -- use strict; use warnings; use Tk; Main( @ARGV ); exit( 0 ); sub Main { my $mw = tkinit(); my $nb = $mw->NoteBook( -backpagecolor => 'red',)->pack(qw/-expand + 1 -fill both /); Colors($nb); $mw->geometry("200x200+200+200"); ## $mw->WidgetDump; $mw->MainLoop; } sub Colors { my( $nb ) = @_; my @color = qw[ pink maroon green OliveDrab4 PaleVioletRed3 RosyBr +own2 PeachPuff4 WhiteSmoke azure3 chartreuse1 coral3 gold1 firebrick4 + linen salmon4 tomato2 ]; for my $red( @color ){ my $frame = $nb->add( $red, -label => $red, ); my $emraf = $frame->Scrolled('Pane', -background => $red)->pac +k(qw/ -expand 1 -fill both /); $emraf->Button( -text => $_, )->pack( -side => (qw/ left right + top bottom/)[rand 4] ) for @color; } }

      Thank you Anonymous Monk, your sample codes helps me to understand on the concept. Appreciate!