|Welcome to the Monastery|
Re: Tk: pack, grid or place?by davidj (Priest)
|on May 13, 2005 at 09:31 UTC||Need Help??|
Here's my take on Tk geometry:
pack is the most popular because its the easiest to use. This ease of use is ideal for applications that require simple layouts. Consequently, tweaking widget layout can be quite burdensome using pack. If what you are developing has a simple layout, by all means, go with pack.
place uses the cartesian coordinate system for locating widgets. This makes coding widget layout more burdensome because you have to code the coordinates. If you have a lot of widgets, this can become quite tedious. However, it gives you much better layout control. You can tweak to your hearts delight and you can do things with place that are extremely difficult to do with pack. Also, with pack, the final layout depends upon the order in which the widgets are packed. This is not true with place. While not generally a problem, I have run into it sometimes.
my personal favorite is the form geometry manager. Instead of using cartesian coordinates, widget placement is indicated by percentages. This is easier for some people to conceptualize. Also, a great advantage of form is that placing widgets relative to other widgets is extremely easy. When I code gui apps, I am a freak for widget placement control and form is much better than pack or place in this regard. Give it a try sometime.
Also, don't really worry about getting caught in any traps by using a particular layout manager. pack, place, grid, and form are all supported, so its not like someone will run your app and have it fail because of the manager you decide to use. The only things you really need to consider are 1) how much control do you want over layout and 2) how is the code going to be maintained. Then, choose your layout manager accordingly.