Search code examples
perlgridtk-toolkitperltk

Vertical placement of grid within a frame while using Grid Geometry Manager in perl-tk


I'm using a grid within a frame and I want to position the grid towards the bottom of the frame. Currently I'm doing this by placing an addition dummy label on line #4 (#114 here). Is there a better way to go about it.

    $frm_sig->grid(-row=>0, -column=>0, -sticky=>'news', -padx=>2);
    $frm_sig->gridColumnconfigure(0, -weight=>1);
    {
        $lbl_sig_dummy->grid(-row=>0, -column=>0, -columnspan=>2);
        $rdb_sig_type_se->grid(-row=>1, -column=>0, -sticky=>'w');
        $rdb_sig_type_diff->grid(-row=>1, -column=>1, -sticky=>'w');

        $lbl_sig_val->grid(-row=>2, -column=>0, -sticky=>'w');
        $txt_sig_val->grid(-row=>2, -column=>1, -sticky=>'w');

        $lbl_sign_val->grid(-row=>3, -column=>0, -sticky=>'w');
        $txt_sign_val->grid(-row=>3, -column=>1, -sticky=>'w');
    }

Solution

  • You should be able to move the rest of the grid to the bottom by setting a non-zero weight on just the first row, without filling it with a dummy label or frame (but if you want something there, that's absolutely fine):

    $frm_sig->gridRowconfigure(0, -weight=>1);
    

    With a new enough Tk, you can anchor the whole gridded area to one edge of its containing widget, but I don't know if you've got a new enough version.