in reply to Re: why is the size of notebooks area smaller than main window
in thread why is the size of notebooks area smaller than main window

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;
  • Comment on Re^2: why is the size of notebooks area smaller than main window (Tk)
  • Download Code

Replies are listed 'Best First'.
Re^3: why is the size of notebooks area smaller than main window (Tk)
by zentara (Cardinal) on May 22, 2017 at 14:34 UTC
    Hi, I always love seeing people use Tk. It's a small-self-contained toolkit which allows you to do may things. Tk and Perl are a perfect low resource toolkit.

    Sorry if my question are too basic.

    I don't really understand what you are trying to do with the scrollbars, but most applications need this sort of canvas-linked scrollbars. See: Re: I seek illumination and knowledge


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