Post by Dean ArnoldPost by zentaraWould a scrolled notebook work for you.
Look at this snippet.
Ahh, just what I was looking for....however, since each notebook
page I'll be displaying is a Scrolled Tk:Text
widget, the extra scrollbars may be a bit confusing...
but I'll play with this...
I tried playing around for self-education, and came up with this.
It uses the Tk:Pane.
There is just one problem I can't seem to figure out.
When you click on Tab 20(at the far right), the textbox is off
screen to the left. I need to find a way to make the tab
focus on itself, or automatically scroll to the left. It's not
much of a problem for only a few items, but it certainly shows up
when you approach 40 tabs.
#!/usr/bin/perl
use warnings;
use strict;
use Tk;
use Tk::NoteBook;
use Tk::Pane;
my $mw = MainWindow->new();
$mw->geometry('600x400+300+100');
my $pane = $mw->Scrolled('Pane', Name => 'scroll test',
-width => 600,
-height => 400,
-scrollbars => 'osoe',
-sticky => 'nw',
);
$pane->pack;
my $nb = $pane->NoteBook(-width=>400,
-background => 'green',
);
my @colors = qw(ivory yellow white black cyan pink snow
linen bisque green azure gray
navy blue turquoise chartreuse khaki
gold peru red);
my %tabs;
for(1..20){
$tabs{$_}{'name'} = 'tab'.$_;
#print 'tab->',$tabs{$_}{'name'},"\n";
my $tab = $nb->add("page$_", -label=>"Student $_");
$tabs{$_}{'text'} = $tab->Scrolled('Text', -scrollbars=>'se',
,-bg => $colors[0])
->pack(-side => 'left',
-anchor => 'n');
$tabs{$_}{'text'}->insert('end', "Tab $_");
$tabs{$_}{'canvas'} = $tab->Canvas(-background=>"yellow")
->pack(-side => 'left',
-anchor => 'n');
$tabs{$_}{'canvas'}->createText(30,40, -text=>"Canvas $_");
#$nb->Resize;
push (@colors,shift(@colors));
}
$nb->pack(qw/-side top/);
$tabs{1}{'text'}->insert('end',"\nAdd this from outside the loop");
MainLoop;
__END__
--
When life conspires against you, and no longer floats your boat,
Don't waste your time with crying, just get on your back and float.