Clear questions and runnable code
get the best and fastest answer
Re: Tk: pack, grid or place?by rinceWind (Monsignor)
|on May 13, 2005 at 15:29 UTC||Need Help??|
Are there strong reasons for using certain geometry managers?
Yes there are, as far as I am concerned. Here are my guidelines.
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.
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.
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.