How to place menu on the bottom

qxyuestc at yahoo.cn qxyuestc at yahoo.cn
Sat Aug 30 05:46:52 EDT 2008


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



More information about the Python-list mailing list