$goMainWindow = new MainWindow;
$goMainWindow->geometry('200x300'); #Exit is lopped off
####
# at ther end of your build_gui sub
$goMainWindow->idletasks;
my $w = $goMainWindow->reqwidth;
my $h = $goMainWindow->reqheight;
print "$w $h\n";
$goMainWindow->minsize($w,$h);
####
#!/usr/bin/perl
use strict;
use Tk;
require Tk::Pane;
our ($goMainWindow);
our (%ghGuiObjs);
our (%ghGuiCBVars);
$| = 1;
&main();
sub main {
buildGui();
MainLoop;
} #end sub main
sub updateA {
if ( $ghGuiCBVars{"nEnableFrameA"} == 1 ) {
$ghGuiObjs{"oContainerA"}->pack(
-expand => '1',
-fill => 'both',
-pady => '5',
);
} else {
$ghGuiObjs{"oContainerA"}->packForget();
}
}
sub updateB {
if ( $ghGuiCBVars{"nEnableFrameB"} == 1 ) {
$ghGuiObjs{"oContainerB"}->pack(
-expand => '1',
-fill => 'both',
-pady => '5',
);
} else {
$ghGuiObjs{"oContainerB"}->packForget();
}
}
sub buildGui {
$goMainWindow = new MainWindow;
my $mf = $goMainWindow->Scrolled('Pane',
-scrollbars => 'osoe',
)->pack(
-expand => '1',
-fill => 'both',
-pady => '5',
);
my ($oLabel) = $mf->Label(
-text => "This is my example",
)->pack(
-padx => '5',
-pady => '5',
-expand => '1',
-fill => 'x',
);
my ($oCbA) = $mf->Checkbutton(
-text => 'Enable A',
-variable => \$ghGuiCBVars{"nEnableFrameA"},
-command => \&updateA,
-anchor => 'w',
);
$ghGuiCBVars{"nEnableFrameA"} = 1;
my ($oFrameA) = $mf->Labelframe(
-labelwidget => $oCbA,
)->pack(
-padx => '5',
-expand => '1',
-fill => 'both',
);
my ($oContainerFrameA) = $oFrameA->Frame(
)->pack(
-expand => '1',
-fill => 'both',
-pady => '5',
);
$ghGuiObjs{"oContainerA"} = $oContainerFrameA;
my ($oLbA) = $oContainerFrameA->Listbox(
-relief => 'groove',
-borderwidth => '5',
-height => '5',
)->pack(
-fill => 'both',
-expand => '1',
);
my ($oCbB) = $mf->Checkbutton(
-text => 'Enable B',
-variable => \$ghGuiCBVars{"nEnableFrameB"},
-command => \&updateB,
-anchor => 'w',
);
$ghGuiCBVars{"nEnableFrameB"} = 1;
my ($oFrameB) = $mf->Labelframe(
-labelwidget => $oCbB,
)->pack(
-padx => '5',
-expand => '1',
-fill => 'both',
);
my ($oContainerFrameB) = $oFrameB->Frame(
)->pack(
-expand => '1',
-fill => 'both',
-pady => '5',
);
$ghGuiObjs{"oContainerB"} = $oContainerFrameB;
my ($oLbB) = $oContainerFrameB->Listbox(
-relief => 'groove',
-borderwidth => '5',
-height => '5',
)->pack(
-fill => 'both',
-expand => '1',
);
my ($oExit) = $goMainWindow->Button(-text => 'Exit',
-command => sub{exit},
)->pack(
-padx => '5',
-pady => '5',
-side => 'bottom',
);
}