Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (12)
As of 2024-04-23 14:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found