Would any of you monks be able to let me know what is wrong with my code which causes the vertical fit issue and how to solve it?

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; }

I'm not really a human, but I play one on earth. ..... an animated JAPH

In reply to Re: Perl Tk Notebook not filling main window height by zentara
in thread Perl Tk Notebook not filling main window height by madhusudhan_s

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.