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.

In reply to Re: Perl/Tk - MainWindow positioning all widgets as centred by graff
in thread Perl/Tk - MainWindow positioning all widgets as centred by crabbdean

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.