in reply to Stretchy grids in Tk

$widget -> grid ($button1, $button2, $button3, -sticky => 'nesw');

Abigail

Replies are listed 'Best First'.
Re: Re: Stretchy grids in Tk
by rinceWind (Monsignor) on Sep 15, 2003 at 13:06 UTC
    I am using -sticky => 'nsew' already. This has the effect of making each button fill the grid cell properly, but the cells are not resized wheh the master is resized.

    For an example, try the calculator example here

    Update: Have updated the calculator example to include the method suggested by herveus, which works.

    --
    I'm Not Just Another Perl Hacker

      Howdy!

      Mastering Perl/Tk, p. 47, says:

      If you use -sticky with your widgets and then resize the window, you'll notice that the widgets don't resize as you would expect. This is because resizing of the cells and the widgets in them is taken car of with the gridColumnconfigure and gridRowconfigure methods...

      Further reading suggests applying a weight of 1 to each row and column. That will allow each to expand. A row/ column with a weight of 0 takes only as much space as it needs; a weight of 2 would take twice as much space as a weight of 1 (so some can be greedier than others).

      yours,
      Michael

        herveus++

        Nice one! That did the trick. Setting the weight to 1 for every row and column enables the stretchiness I was looking for.

        I will also look at buying this book. This will relieve some of my frustrations in the documentation that comes with Tk.

        --
        I'm Not Just Another Perl Hacker