Hi
My main Tk window has three frames on it - topframe, hlistframe and bottomframe. I want all these frames to be visible when it opens witha geometry of (480x160). But when my hlistframe has 2 rows of data, all frames are visible. But if the data row is increased to 4, the bottomframe is disappearing and I have to stretch the gui to make the bottomframe visible which I do not want. I want the gui size to be as small as (480x160) always and use the scrollbar on the right side when I have many rows of data

Below is my code, please change the @keys array to see the difference

use strict; use warnings; use Tk; use Tk::HList; use Tk::ItemStyle; use Tk::BrowseEntry; use Tk::Toplevel; use Tk::Menubutton; my $sec = 10; my $data = { user1 => { "irun"=>{ "feature" => "queue", "vendor" => "abcd", "issued" => "100", "inuse" => 26 }, }, user2 => { "irun"=>{ "feature" => "queue", "vendor" => "abcd", "issued" => "510", "inuse" => 27 }, }, user2 => { "irun"=>{ "feature" => "batch", "vendor" => "pqrs", "issued" => "100", "inuse" => 222 }, }, user3 => { "irun"=>{ "feature" => "queue", "vendor" => "mnop", "issued" => "500", "inuse" => 244 }, }, user4 => { "irun"=>{ "feature" => "queue", "vendor" => "uvwx", "issued" => "400", "inuse" => 200 }, }, }; # Making the GUI my $mw = tkinit; # new MainWindow; $mw->title("gui"); $mw->geometry("480x160"); my $topframe = $mw->Frame(-width=>5,-height=>10)->pack(-side=>'top',-a +nchor=>'nw',-expand=>0); $topframe->Label(-text => "USER: user1")->pack(-side => 'left',-anchor + => 'w',-padx => 0); $topframe->Label(-text => "Set time(sec)")->pack(-side => 'left',-anch +or => 'w',-padx => 0); my $frequency = $topframe->Entry(-width=> 5,-textvariable=> \$sec)->pa +ck(-side => 'left',-anchor => 'nw',-padx => 0); $topframe->Label(-text => "Select File")->pack(-side => 'left',-anchor + => 'w',-padx => 0); #Help Menu my $menuButton = $topframe->Menubutton(-text => 'Help')->pack(-side=>' +right'); my $menu = $menuButton->Menu (-tearoff => 0); my $user_manual = $menuButton-> cascade(-label => "Manual", -tearoff = +> 0); my $pref = $menuButton-> cascade(-label => "Preference", -tearoff => 0 +); $topframe->BrowseEntry( -state => 'normal', )->pack(-side=>'right',-anchor =>' +e'); my $hlistframe = $mw->Frame()->pack(-fill => 'both',-expand=>1); my $h +l; my $bottomframe = $mw->Frame()->pack(-fill => 'both', -expand => 0); $bottomframe->Button(-text => "Display File",-command => sub {})->pack +(-side=>'right',-anchor => 'ne',-fill=>'x'); my ($general,$label1,$label2,$label3,$label4,$label5,$label6,$label7); $hl = $hlistframe->Scrolled('HList', -scrollbars => 'ose', -columns =>7 , -header => 1, -height => -1, )->pack(-fill => 'both',-expand =>1 ); $label1 = $hl->Label(-text => "Feature", -anchor => 'w'); $hl->headerCreate(0,-itemtype => 'window',-widget => $label1) ; $label2 = $hl->Label(-text => "Vendor", -anchor => 'w'); $hl->headerCreate(1,-itemtype => 'window',-widget => $label2); $label3 = $hl->Label(-text => "Available", -anchor => 'w'); $hl->headerCreate(2,-itemtype => 'window',-widget => $label3); $label4 = $hl->Label(-text => "co lics.", -anchor => 'w'); $hl->headerCreate(3,-itemtype => 'window',-widget => $label4); $label5 = $hl->Label(-text => "co_lics.%", -anchor => 'w'); $hl->headerCreate(4,-itemtype => 'window',-widget => $label5); $label6 = $hl->Label(-text => "co_lic_user", -anchor => 'w'); $hl->headerCreate(5,-itemtype => 'window',-widget => $label6); $label7 = $hl->Label(-text => "co_user%", -anchor => 'w'); $hl->headerCreate(6,-itemtype => 'window',-widget => $label7); $general = $hl->ItemStyle('text', -selectforeground =>'black', -ancho +r =>'center'); #my @keys = qw (user1 user2 user3 user4); my @keys = qw (user1 user2 ); my $path = 0; foreach my $key (@keys) { for my $tool (sort keys %{$data->{$key}}) { _insertData($path,$tool,$key); $path++; } } sub _insertData { my $path = shift; my $tool = shift; my $usr = shift; $hl->add($path); $hl->itemCreate($path,0,-text=> $data->{$usr}->{$tool}->{feature}, +-style => $general); $hl->itemCreate($path,1,-text=> $data->{$usr}->{$tool}->{vendor}, +-style => $general); $hl->itemCreate($path,2,-text=> $data->{$usr}->{$tool}->{issued}, +-style => $general); $hl->itemCreate($path,3,-text=> $data->{$usr}->{$tool}->{inuse}, - +style => $general); $hl->itemCreate($path,4,-text=> "20%", -style => $general); $hl->itemCreate($path,5,-text=> 'N/A', -style => $general); $hl->itemCreate($path,6,-text=> "30%", -style => $general); } MainLoop;

In reply to tk frame packing showing inconsistent behaviour by ghosh123

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.