in reply to Perl/Tk - MainWindow positioning all widgets as centred

I think you could have snipped quite a bit more code in order to focus attention on the problem. Still, consider the alternative below, which keeps all the buttons etc at the top when the window is made larger.

I'm sorry that I'm a bit at a loss to explain the subtleties involved here, except that you probably made the wrong assumption about how to organize the frames and buttons. Basically, you were using the grid manager on the main window (together with a menu bar, which might have been confusing for the grid manager), and you had separate frames within the main window for each button -- which had no impact on solving your problem.

In the version below (with a bit more stuff clipped out) there is one frame to contain all the buttons, and the buttons themselves use the grid manager to control their positions and extents within that one frame. (As a rule, using fewer widgets is a good thing.)

use strict; use warnings; use Tk; my $shiftselect; ########################### ## Make Main Window my $mw = MainWindow->new (-title => 'opzTul'); $mw->resizable('false','true'); # (menu bar left out for brevity) my $grid = $mw->Frame()->pack; my $All = $grid->Radiobutton(-text => 'All day', -variable => \$shiftselect, -value => 'All' ); my $goButton = $grid->Button(-text => 'Go!', -width => 27, -command => sub {print "Go\n"} ); my $refButton = $grid->Button (-text => 'Refresh', -width => 27, -command => sub {print "Refresh\n"} ); my $quitButton = $grid->Button (-text => 'Quit', -width => 27, -command => \&quit ); ########################### ## Pack and build all elements of the window $All -> grid (-row => 2, -columnspan => 4, -sticky => 'n', -pady => 5, -padx => 5,); $goButton->grid (-row => 3, -columnspan => 4, -sticky => 'n', -pady => 5, -padx => 5, ); $refButton -> grid (-row => 4, -columnspan => 4, -sticky => 'n', -padx => 2, -pady => 2); $quitButton -> grid (-row => 6, -columnspan => 4, -sticky => 'n', -padx => 2, -pady => 2); MainLoop; sub quit { print "Quitting ..\n"; $mw -> destroy; }
update: it turns out that the "-sticky => 'n'" option in those grid() geometry manager calls is unnecessary -- this code works the same whether those lines are in or out. Sorry, but I can't seem to recall right now how to get other behaviors, such as expanding to fill available space, etc.