in reply to Perl Tk Notebook not filling main window height
Hi, I have a hard time trying to understand why you create a canvas, add notebooks to the canvas, and add windows into the canvas to hold the notebooks, $mw->Popup, $mw->withdraw.???? Did you just cut-copy-and-paste a bunch of code together and hoped it worked? :-)
Notebooks are hard to get working properly when it comes to resizing, see: perltk autoresize following users resize
Here is a hack to make it work somewhat correctly, just make your widgets larger, I upped them to 1000. I also didn't pack them until just before the Mainloop is called. This gives them time to size themselves before being displayed.
#!/usr/bin/perl use warnings; use strict; use Tk; use Tk::NoteBook; use Tk::Pane; my $mw = MainWindow->new; $mw->geometry("600x400"); my $pane = $mw->Scrolled('Pane',-height => 1000,-bg=>'black', -scrollb +ars => "osoe"); my $n = $pane->NoteBook(); for ( 1 .. 20 ){ my $title = "mytab $_"; $_ = create_tab("$title"); } #pack widgets after being fully built $n->pack(-expand=> 1, -fill=>'both', -expand=>1, -anchor=>'nw',-side = +> 'top'); $pane->pack(-fill => 'both', -expand => 1); $mw->update; MainLoop; sub create_tab { my $tabname = shift; my $tn = $n->add($tabname, -label => $tabname, -underline => 0, #-raisecmd =>sub{ $mw->update} ); my $t = $tn->Scrolled("Text", -scrollbars => "onow", -height=> 100 +0, -bg=> 'lightseagreen', -wrap => 'none')->pack(-expand => 1, -fill => 'both', -anch +or=> 'nw'); $t->tagConfigure ('bold', -font => [ -size => 20, -weight => 'bold +' ]); for (1..1000){$t->insert('end',$tabname. "_$_\n",['bold'])}; return $t; }
|
|---|