Help please with menubars

Jeff Epler jepler at unpythonic.net
Sun Sep 29 10:47:39 EDT 2002


On Sat, Sep 28, 2002 at 03:54:52AM +0000, mongo57a at comcast.net wrote:
> Specifically: I have an "exit" item on the
> menubar and if the user clicks on "exit", the window should be closed. What
> I don't want is a pulldown with "exit" as a button option. Anybody know how
> to do this? Thanks.

I have never read a single guide to User Interface Design that said this
was a good idea.

First, all modern GUIs have a standard decoration for "Close Window",
as well as a standard for File->Exit (plus Ctrl-Q/Command-Q shortcut).
Why add another, non-standard way to exit the application?  (A similar
argument exists for not placing "Exit" on a toolbar:  Toolbars are for
frequently-accessed commands, but Exit is invoked only once per session)

Second, having a destructive command invoked simply by clicking on the
menubar violates the user's expectation that an action will not be taken
until she chooses an item from inside a menu.  In a pulldown menu there is
a visual cue that an item is a cascade (the right-pointing triangle) but
there is no such standard visual cue in the toplevel menu.  Instead, they
are all assumed to act as cascades.

Third, if you're really insistent on doing this, code like the following
"works" for me:
    >>> import Tkinter
    >>> x = Tkinter.Tk()
    >>> m = Tkinter.Menu(x)
    >>> x.configure(menu=m)
    >>> def p(): print "clicked" 
    ... 
    >>> m.add_command(label="Blah", underline=0, command=p)
    >>> # I click "Blah" or press Alt-B
    clicked

While the current crap^H^Hop of "skinnable" applications seem to indicate
otherwise, there's really no value in making your program arbitrarily
different from the standard programs that run on your platform.  I hope
you'll reconsider.  Eventual users of your software will thank you.

Jeff




More information about the Python-list mailing list