diff --git a/twander.py b/twander.py index ee17d94..9ea8ff5 100755 --- a/twander.py +++ b/twander.py @@ -6,7 +6,7 @@ # Program Information PROGNAME = "twander" -RCSID = "$Id: twander.py,v 3.137 2004/03/10 09:37:52 tundra Exp $" +RCSID = "$Id: twander.py,v 3.138 2004/03/10 10:56:08 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -882,6 +882,7 @@ # Cleanout any old configuration data UI.CmdTable = {} + UI.Commands = [] UI.DirSCKeys = ["", "", "", "", "", "", "", "", "", "", "", ""] UI.SymTable = {} @@ -999,12 +1000,6 @@ for o in x.keys(): globals()[o] = x[o] - # Initialize the command menu - UI.CmdBtn.menu.delete(0,END) - - # And disable it - UI.CmdBtn.config(state=DISABLED) - # If user specified a config file, try that # Otherwise use HOME == either $HOME or ./ @@ -1023,6 +1018,29 @@ if DoOptionsProcessing: ProcessOptions() + # Initialize the command menu + UI.CmdBtn.menu.delete(0,END) + + # And disable it + UI.CmdBtn.config(state=DISABLED) + + # Now load the menu with the final set of commands + + for cmdkey in UI.Commands: + cmdname = UI.CmdTable[cmdkey][0] + UI.CmdBtn.menu.add_command(label=PadString(cmdname, CMDMENU_WIDTH) + "(" + cmdkey + ")", + command=lambda cmd=cmdkey: CommandMenuSelection(cmd)) + # Enable the menu if it has entries. + # If no commands are defined, warn the user. + + if UI.CmdBtn.menu.index(END): + UI.CmdBtn['menu'] = UI.CmdBtn.menu + UI.CmdBtn.configure(state=NORMAL) + else: + WrnMsg(wNOCMDS) + + + return 'break' # End of 'ProcessConfiguration()' @@ -1405,8 +1423,17 @@ # overwritten. UI.CmdTable[cmdkey] = [cmdname, cmd] - UI.CmdBtn.menu.add_command(label=PadString(cmdname, CMDMENU_WIDTH) + "(" + cmdkey + ")", - command=lambda cmd=cmdkey: CommandMenuSelection(cmd)) + + # Keep track of the order in which the commands + # were defined - we want them to show up that + # way in the Command Menu so user can put + # most-used commands near the top. + # Do this suppressing duplicates. + + if cmdkey in UI.Commands: + UI.Commands.remove(cmdkey) + + UI.Commands.append(cmdkey) else: WrnMsg(wBADCFGLINE % (num, line), fn=file) @@ -1443,16 +1470,6 @@ # Rebind all the handlers UI.BindAllHandlers() - # Set the Command Menu Contents, if any, - # and enable the menu if it has entries. - # If no commands are defined, warn the user. - - if UI.CmdBtn.menu.index(END): - UI.CmdBtn['menu'] = UI.CmdBtn.menu - UI.CmdBtn.configure(state=NORMAL) - else: - WrnMsg(wNOCMDS) - # Any user-set options have now been read, set the GUI for i in (UI.CmdBtn, UI.DirBtn, UI.HistBtn, UI.SortBtn, UI.WildBtn, UI.HelpBtn): @@ -4147,7 +4164,7 @@ cmd = UI.CmdTable[key][1] debuginfo.append(PadString(key + " " + name, dCMDWIDTH) + cmd) - debuginfo.sort() + debuginfo.sort() return debuginfo # End of 'GetCommandTable()'