Menubuttons located in the middle of menubar
how do I put my menu bar buttons on menu bar's left ? Right now I pack() them with side=LEFT but still they're in the middle. Here's the code for my menu bar: http://pastebi开发者_运维问答n.com/bgncELcb
I recommend against creating menubars a) with frames and menubuttons, and b) with menus in non-standard places. You should use the menu
option of your toplevel window if you're at all interested in usability. However, since you specifically asked about menubuttons in the middle of a frame...
If you want something precisely in the middle, one thing you can do is break your menu into three sections, a left, middle and right. Place those three subframes inside your "menubar" frame. Use grid to give the left and right sections the most weight
(and equal to each other, so the middle stays in the middle). You can then pack a button or buttons in the middle frame and they will remain in the middle.
Another choice is to use place, and set the relative X position to .5 and the anchor to "n". That is probably the easiest, though you can have problems with overlapping buttons if they don't all fit because the user resized the window.
The option you chose -- pack
-- is the most difficult route to take. pack by it's very nature is designed to pack things along edges. Again, you can use three subframes, but pack
isn't the natural choice here.
My advice: rethink why you want a non-standard menubar. Use a real menubar with menu buttons along the left like 99.9% of all other apps in the world. Your users will thank you.
What does menubar.pack(side=LEFT) give you? Can you also try with menubar.pack()?
精彩评论