469,647 Members | 1,804 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,647 developers. It's quick & easy.

How to place menu on the bottom

#!/usr/bin/env python

import sys
import os

from tkinter import *

def callback(self):
#int this snippet, all menu entries use the same callback...
print("callback")
class DemoMenu():
def __init__(self):
self.dataTemp = ""
self.createWidgets()

def createWidgets(self): # create application GUI
self.rootWin = Tk()
self.rootWin.minsize(width=800, height=600)
self.rootWin.maxsize(width=800, height=600)
self.rootWin.title = ("JoeQ Menu test...")

self.mainFrame = Frame(self.rootWin)

self.createMenu()

def createMenu(self): # create menu
menuFrame = Frame(self.rootWin)
menuFrame.pack(side=BOTTOM, fill=X)

menuBar = Menu(menuFrame, tearoff=1)

filemenu = Menu(menuBar, tearoff=0)
filemenu.add_command(label="Open...", command=callback)
filemenu.add_separator()
filemenu.add_command(label="Exit", command=callback)

menuBar.add_cascade(label="File", menu=filemenu)

self.rootWin.config(menu=menuBar)

return menuBar

def start(self):
self.rootWin.mainloop()
if __name__ == '__main__':
demomenu = DemoMenu()
demomenu.start()
################################################## ####
I want to place the menu on the bottom (menuFrame.pack(side=BOTTOM,
fill=X)). But it does not work. Why?
Aug 30 '08 #1
3 1296
qx******@yahoo.cn wrote:
self.rootWin.config(menu=menuBar)
I want to place the menu on the bottom (menuFrame.pack(side=BOTTOM,
fill=X)). But it does not work. Why?
menubars that are configured via the window menu option are rendered by
the underlying window system.

to create a stand-alone menu bar, create a frame and pack or grid it
where you want it, then add Menubutton widgets to it, and attach your
pulldown menus to those buttons.

the following wrapper supports both menu styles; look at the "else"
clauses in the various "if use_native_menus" statements for code samples:

http://svn.effbot.org/public/stuff/s...nter/tkMenu.py

</F>

Aug 30 '08 #2
On Aug 30, 6:04*pm, Fredrik Lundh <fred...@pythonware.comwrote:
qxyue...@yahoo.cn wrote:
* * * * self.rootWin.config(menu=menuBar)
I want to place the menu on the bottom (menuFrame.pack(side=BOTTOM,
fill=X)). But it does not work. Why?

menubars that are configured via the window menu option are rendered by
the underlying window system.

to create a stand-alone menu bar, create a frame and pack or grid it
where you want it, then add Menubutton widgets to it, and attach your
pulldown menus to those buttons.

the following wrapper supports both menu styles; look at the "else"
clauses in the various "if use_native_menus" statements for code samples:

http://svn.effbot.org/public/stuff/s...nter/tkMenu.py

</F>
step1: I first create a widget "menuFrame" which is belong to the
rootWin
....menuFrame = Frame(self.rootWin)
step2: then I put the widget to the bottom of the rootWin
....menuFrame.pack(side=BOTTOM, fill=X)
step3: I create a menu belong to the menuFrame.
....menuBar = Menu(menuFrame, tearoff=1)
since menuFrame should be placed to the bottom, so does the menuBar in
my opinion. What the problem is?
Aug 30 '08 #3
qx******@yahoo.cn wrote:
What the problem is?
the menu is drawn by the window system when you use the "menu" option,
not by Tkinter.

</F>

Aug 30 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Veerle | last post: by
2 posts views Thread by RWD | last post: by
2 posts views Thread by Jackson Yap | last post: by
reply views Thread by Garmt de Vries-Uiterweerd | last post: by
2 posts views Thread by Ravi Joshi | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.