tkinter menus
Keith Murphy
kpmurphy at my-deja.com
Mon Jul 10 13:59:28 EDT 2000
In article <5vujmsg8hdf54luae6e2c0jivv93qheu9h at 4ax.com>,
mwr at hsl.tcp.co.uk wrote:
> On Mon, 10 Jul 2000 14:26:40 GMT, Keith Murphy <kpmurphy at my-deja.com>
> wrote:
>
> >menu, menu... anyone, anyone?
> >
> > How do you configure top-level menu entries? I'd like to put a
'help'
> >menu (and possibly others) on the right end of the menu bar. I've
seen
> >examples where you make your own frame... but there has to be a way
> >built in... doesn't there? :)
> >
> In Tkinter, when you use the appropriate geometry manager to put the
> button in the menu bar. E.g:
> helpButton = Menubutton(myMenuBar, ...)
> helpButton.Pack(side=RIGHT, ...)
>
> Or if you're using Pmw, then you can do something like:
> myMenuBar = Pmw.MenuBar(...)
> myMenuBar.addmenu(side=RIGHT,...)
>
> --
> Martin Rand
> Highfield Software Ltd
> mwr at highfield-software.co.uk
> Phone: +44 (0)23 8025 2445
> Fax: +44 (0)23 8025 2445
>
well i am using a system menubar, not one i've created. i'm using
fredrik lundh's 'an introduction to tkinter'
(http://www.pythonware.com/library/tkinter/introduction/index.htm) as my
guide. here is an example he uses:
# File: menu-example-2.py
from Tkinter import *
root = Tk()
def hello():
print "hello!"
# create a toplevel menu
menubar = Menu(root)
menubar.add_command(label="Hello!", command=hello)
menubar.add_command(label="Quit!", command=root.quit)
# display the menu
root.config(menu=menubar)
mainloop()
...if you try and pack or anything, you will get the following message:
TclError: can't pack ".1977984.1980464": it's a top-level window
... any more help? thanks :)
-->keith
Sent via Deja.com http://www.deja.com/
Before you buy.
More information about the Python-list
mailing list