Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: Tk: pack, grid or place?

by rinceWind (Monsignor)
on May 13, 2005 at 15:29 UTC ( #456776=note: print w/replies, xml ) Need Help??

in reply to Tk: pack, grid or place?

Are there strong reasons for using certain geometry managers?

Yes there are, as far as I am concerned. Here are my guidelines.

  1. pack
  2. This is the simplest of the geomentry managers to use. I think of it as a concertina cardboard box with books stacked against each of the sides. Imagine the concertina contracts to minimise the space in the middle.

    Most of the time, you just stack against one side. However, the other options are useful if you want to add widgets in a different order.

  3. grid
  4. Pack is all very well for simple apps. And you can nest frames with widgets packing in different directions.

    But, the rows and columns will not line up. If the model of what you want to do fits better a matrix of cells, the grid geometry manager gives you this. Think Excel spreadsheet, or better, HTML table.

  5. place
  6. With the other two, positioning of widgets is automatic, and the size of the tol level window fits the size of what it contains.

    The place geometry manager, on the other hand, works like more traditional GUI programming languages, e.g. Visual Basic. Each widget is placed with coordinates of its origin and an exact size.

    place is used when the user has the ability to drag and move widgets around. However, in Tk, this type of activity tends to be done with a canvas.

There are other geometry managers, but these tend to be more specialised and less widely used.

I'm Not Just Another Perl Hacker

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://456776]
and all is calm...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2018-02-21 00:33 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (274 votes). Check out past polls.