How to place menu on the bottom

Q

qxyuestc

#!/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?
 
F

Fredrik Lundh

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/sandbox/tkinter/tkMenu.py

</F>
 
Q

qxyuestc

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/sandbox/tkinter/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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top