Help please with menubars

Chad Netzer cnetzer at mail.arc.nasa.gov
Sat Sep 28 22:23:04 EDT 2002


On Saturday 28 September 2002 06:30, andy surany wrote:
> Thanks Chad.

No problem; I'm posting my reply to the newsgroup, because I think it 
is relevant.

> Yes, Tk.
>
> The problem with using add.menubar is that I end up with a cascade.

Huh?  Not in the example that I posted...

> But I hadn't thought of a bind. I know that I can bind to a button -
> but this is an item on a menubar. I'm not sure how to do that.

Me neither. :)  It really is more effort than it is worth; and I think 
you don't need it.

> BTW, what I am encoding is a menubar with 5 top level items. The
> first 4 are cacading/pulldown (no problems!), but the fifth is simply
> an "Exit" on the menubar. Click it, and the window should be history.

That was almost exactly what the code I posted did...  Hmmmph; Here is 
a revision that exits when you click on the "Exit" entry in the 
menubar, WITHOUT dropping down a menu.  I also added a separate menu 
entry that does cascade down, just to show you it can be done.

If this isn't what you need, then I have no clue what you mean; it 
would be best to post your code (or the relevant portions), to see how 
you are attempting to use menus.

I'm making it an attachment, so it should be easy for you to save and 
run it.  Please DO run it, if you haven't, before replying, and let me 
know if it doesn't work as I say it should.

Also, by using the "menu" option of a Toplevel, this code will 
integrate much better with the system you are on, than if you try to 
make your own custom "menubar", using a Frame and menubuttons, for 
example.  On the Mac, for example, this code follows the systems 
menubar conventions (per desktop, not per window).

-- 

Chad Netzer
cnetzer at mail.arc.nasa.gov
-------------- next part --------------
A non-text attachment was scrubbed...
Name: menubar_test2.py
Type: text/x-java
Size: 654 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20020928/c0e9f2d0/attachment.java>


More information about the Python-list mailing list