Thank you Ken for that solution. It works!!
Now i added new subroutines to create tabs and add certain things on the tabs. when this program is run i notice that the tab content gets restricted vertically while horizontally it fits the main window width.
I realized that this is due to pack present in the subroutine create_tab.
It so happens that i need the tab scrollbar and a main window scroll bar.
When i comment this pack my content and the tab and scrollbars vanish.
How should i modify the program to have a vertical fit of the tab to main window height and contents on the tab seen.
Sorry if my question are too basic.
#!/usr/bin/perl
use Tk;
#use strict;
require Tk::NoteBook;
require Tk::LabEntry;
require Tk::Scrollbar;
our $mw = MainWindow->new;
$mw->geometry("800x1000");
my $canvas = $mw->Scrolled('Canvas', -scrollbars => "s")->pack(-fill =
+> 'both', -expand => 1);
$mw->withdraw();
$mw->Popup;
# Create the NoteBook and add 2 pages, which are really
# Frames with tabs. Given that, we create LabEntry
# widgets and pack them as usual.
our $n = $canvas->NoteBook(-dynamicgeometry => 'true')->pack( -fill=>'
+both', -expand=>1);
$n->pack( -expand => "yes", -fill => "both", -side => "top" );
for ( 1 .. 20 ){
my $title = "mytab $_";
#$n->add( $_, -label => $title );
$_ = create_tab("$title");
create_tab_labentry($_, \$folder_name, "folder name: ");
}
### embed the notebook widget into the canvas
my $nb_in_canvas = $canvas->createWindow( 0, 0, -window => $n, -anchor
+ => 'nw' );
$canvas->update;
### the whole notebook is larger than what can be initially displayed
### so we'll have to sroll it later on in the program
$canvas->configure( -scrollregion => [0,0,$n->reqwidth,$n->reqheight])
+;
sub create_tab
{
my $tabname = shift;
my $tn = $n->add($tabname, -label => $tabname, -underline => 0);
$t = $tn->Scrolled("Text", -scrollbars => "e", -wrap => 'none')->p
+ack(-expand => 1, -fill => 'both');
$t->tagConfigure ('bold', -font => [ -size => 0, -weight => 'bold'
+ ]);
return $t;
}
sub create_tab_labentry
{
my $tabname = shift;
my $fc_address = shift;
my $field_label = shift;
$w = $tabname->Button(-text => $field_label, -relief => 'raised',
+-width => 66);
$tabname->windowCreate('end', -window => $w);
$w = $tabname->Entry(-width => 35, -textvariable => $fc_address);
$tabname->windowCreate('end', -window => $w);
$tabname->insert('end', "\n");
}
MainLoop;