General Design Hints

This section discusses some common-sense techniques that you can use to make designing your GUI a little easier.

Widget Layout

In almost all cases, pack is the only geometry manager you’ll need. Start by deciding what widgets you want at the top of your window. Put them in a frame, packing them from left to right. Then pack the frame against the top of the main window.

Repeat this process until all your widgets have been created.

This method works for about 95 percent of the GUIs I’ve designed. (The other 5 percent required the grid geometry manager.)

Handle Placement Then Expansion

Don’t worry about the –expand and –fill options until you have your widgets where you want them. Then go back and add in these options.

The next step is to test your program and resize the main window. If you did your –expand and –fill options right, things should look nice. If not, try again.

Use ptkdb

The ptkdb debugger is great for Tk applications. If you use the normal debugger, you won’t see your widgets until you enter the MainLoop. Because of the way the ptkdb debugger works, when you create a widget and manage it, the widget appears instantly.

This means that if you are using pack to manage your widgets, you can see exactly how pack is placing your widgets on the screen.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset