in reply to Make Tk Optionmenu same height as Button

In my experience, using -pady, -padx doesn't work out that well.

In this case, the MenuButton idea is a great one as I think it is the same size as other buttons.

The more general advice is to use more sub-frames and the various anchor and centering options to get things to "line up". I draw "pencil on paper" diagrams before attempting to write a Tk GUI. This helps a lot! Draw diagrams showing the frames. Think sub-frame to get things to line up. Stay away from pixel oriented stuff.

Different users will have different frame resolutions and use say "large fonts" instead of "small fonts" - basically you are "doomed" if you deal with pixels. If you have a frame and pack in 2 widgets, that are are packed in left to right and then "centered" within that frame, then this work (in my experience).

GUI coding is one area where "mileage varies a lot!". But I think the basic advice of thinking "sub-frames" will take you a very long way down the road.

  • Comment on Re: Make Tk Optionmenu same height as Button

Replies are listed 'Best First'.
Re^2: Make Tk Optionmenu same height as Button
by chessgui (Scribe) on Jan 25, 2012 at 02:27 UTC
    This prog is for my own use. Portability is not an issue for me. In my case -pady=>2 creates a Button smaller, -pady=>3 a Button bigger than an Optionmenu :). So this lazy unportable trial and error solution does not work for me. Now I may have to learn creating menus. At first sight it looks much more complicated (how to reproduce Optionmenu functionality with a Menubutton?). Also you seem to be limited to a single menu bar / main window (at the top). I have several control panels in my main window scattered all around the place.

    Your sub-frame approach I fully appreciate. From my experience I have learned to put everything in void container frames (even in separate Toplevel windows which can be iconified). Every functional module in my prog gets a container frame to start with in the constructor which it can populate but knows nothing else about the world.