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