Tkinter menus made easy

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Thu Mar 27 11:55:13 EDT 2008


On Mar 27, 3:54 pm, MartinRineh... at gmail.com wrote:
> Writing Tkinter menu code used to be rather tedious, uninspiring work.
> I figured that I could delegate the job to a program:

I did develop a proggy that takes the following as input, it's part of
my "agui" project, you can use it as an idea to improve your code:

menudef = """
File
    New,        callNew,            Ctrl-N
    New Window, callNewWindow,      Ctrl-Shift-N
    __
    Open,       lambda e=0:para(1), Ctrl-O
    __
    Save,       lambda e=0:para(2), Ctrl-S
    Save As,    CallSaveAs,         F12
    __
    Minimize,   called,             Ctrl-M
    Magic,      called,             Alt-X
Edit
    Cut,        called,             Ctrl-X
    Copy,       called,             Ctrl-C
    Paste,      called,             Ctrl-V
    __
    Align
        Left,
        Right,
        ___
"""
m = Menu(root, globals(), menudef)

Callee:
def __init__(self, root, globalVars, menuDef, font=None, fieldSep=",",
itemSep="_"):
...

Bye,
bearophile



More information about the Python-list mailing list