Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Here is my solution. The main differences are:
  • add minimum size for the main window
  • top and bottom frame have expand = 0 and fill = 'x'
  • Add height = -1 to HList
use strict; use warnings; use Tk; use Tk::HList; use Tk::ItemStyle; use Tk::BrowseEntry; use Tk::FontDialog; my $mw = MainWindow->new; $mw->title("View"); $mw->minsize(560, 180); my ($user, $sec, $selectfile) = ('user', 30, 'file'); my %url; my $userframe = $mw->Frame()->pack( -side => 'top', -fill => 'both', -expand => +0 ); my $hlistframe = $mw->Frame()->pack( -side => 'top', -fill => 'both', -expand => +1 ); my $bottomframe = $mw->Frame()->pack( -fill => 'x', -expand => 0 ); my $menubutton = $userframe->Menubutton( -text => "Font", )->pack( -side => 'left +' ); $menubutton->command( -label => "Change", -command => sub { my $font = $mw->FontDialog->Show; $mw->RefontTree( -font => $font ) if defined $font; } ); $userframe->Label( -text => "USER: $user" ) ->pack( -side => 'left', -anchor => 'w', -padx => 10 ); $userframe->Label( -text => "Set time(sec)" ) ->pack( -side => 'left', -anchor => 'w', -padx => 10 ); my $frequency = $userframe->Entry( -width => 5, -textvariable => \$sec + ) ->pack( -side => 'left', -anchor => 'nw', -padx => 10 ); $userframe->Label( -text => "Select File" ) ->pack( -side => 'left', -anchor => 'w', -padx => 10 ); $userframe->BrowseEntry( -state => 'normal', -choices => [ keys %url ], -variable => \$selectfile, -browsecmd => \&read_file, )->pack( -side => 'left', -anchor => 'w' ); my $hl = $hlistframe->Scrolled( 'HList', -scrollbars => 'ose', -columns => 7, -header => 1, -height => -1, -command => sub { print "AAA\n"; }, )->pack( -fill => 'both', -expand => 1 ); my $label1 = $hl->Label( -text => "Tool", -anchor => 'w' ); $hl->headerCreate( 0, -itemtype => 'window', -widget => $label1 ); my $label2 = $hl->Label( -text => "Vendor", -anchor => 'w' ); $hl->headerCreate( 1, -itemtype => 'window', -widget => $label2 ); my $label3 = $hl->Label( -text => "Available", -anchor => 'w' ); $hl->headerCreate( 2, -itemtype => 'window', -widget => $label3 ); my $label4 = $hl->Label( -text => "num.", -anchor => 'w' ); $hl->headerCreate( 3, -itemtype => 'window', -widget => $label4 ); my $label5 = $hl->Label( -text => "usage%", -anchor => 'w' ); $hl->headerCreate( 4, -itemtype => 'window', -widget => $label5 ); my $label6 = $hl->Label( -text => "user", -anchor => 'w' ); $hl->headerCreate( 5, -itemtype => 'window', -widget => $label6 ); my $label7 = $hl->Label( -text => "user%", -anchor => 'w' ); $hl->headerCreate( 6, -itemtype => 'window', -widget => $label7 ); $bottomframe->Button( -text => "Display File", -command => \&dumpOnTer +minal ) ->pack( -side => 'right', -anchor => 'ne', -fill => 'x' ); MainLoop;

This answers also to your other question regarding the font and window dimensions change.

Update: Changed the intro paragraph. The dimension of the window doesn't always change, only when it accommodates to bigger contents.

Update2: Updated the update :-)


In reply to Re: perl tk frame packing question by stefbv
in thread perl tk frame packing question 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 meditating upon the Monastery: (6)
As of 2024-04-23 14:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found