diff --git a/twander.py b/twander.py index 051b620..8ccee1b 100755 --- a/twander.py +++ b/twander.py @@ -6,7 +6,7 @@ # Program Information PROGNAME = "twander" -RCSID = "$Id: twander.py,v 2.81 2003/01/28 01:22:14 tundra Exp $" +RCSID = "$Id: twander.py,v 2.82 2003/01/28 17:37:46 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -78,6 +78,8 @@ # General Program Commands CLRHIST = '' # Clear Command History +FONTDECR = '' # Decrease font size +FONTINCR = '' # Increase font size MOUSECTX = '' # Pop-up Context Menu MOUSEDIR = '' # Pop-up Directory Menu KEYPRESS = '' # Any keypress (for commands) @@ -621,6 +623,8 @@ # parsing process. UI.KeyBindings = {"CLRHIST":CLRHIST, + "FONTDECR":FONTDECR, + "FONTINCR":FONTINCR, "MOUSECTX":MOUSECTX, "MOUSEDIR":MOUSEDIR, "KEYPRESS":KEYPRESS, @@ -919,6 +923,92 @@ ##### +# Setup The GUI Visual Parameters, Menus, & Help Information +##### + +def SetupGUI(): + + # Start in detailed mode unless details are inhibited + UI.SetDetailedView(~NODETAILS) + + # 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.HelpBtn): + i.config(foreground=MFCOLOR, background=MBCOLOR, font=(MFNAME, MFSZ, MFWT)) + i.menu.config(foreground=MFCOLOR, background=MBCOLOR, font=(MFNAME, MFSZ, MFWT)) + + # Set Menu Bar background to match buttons + UI.mBar.config(background=MBARCOL) + + UI.DirList.config(font=(FNAME, FSZ, FWT), + foreground=FCOLOR, background=BCOLOR, + height=HEIGHT, width=WIDTH) + + # Make sure menus conform to max lengths (which may have changed). + + UpdateMenu(UI.DirBtn, UI.AllDirs, MAXDIR, MAXDIRBUF, LoadDirList, sort=TRUE) + UpdateMenu(UI.HistBtn, UI.CmdHist, MAXHIST, MAXHISTBUF, KeyRunCommand, fakeevent=TRUE) + + ##### + # Initialize Help Menu with latest information + ##### + + # Clear out existing content + + UI.HelpBtn.config(state=DISABLED) + UI.HelpBtn.menu.delete(0,END) + + + # Update the cascading submenus + # We iterate across tuples of (Menu Name, Menu Variable, List Of Items) + + for mname, mvbl, mlist in ((hUSERVBLS, UI.UserVbls, GetUserVbls()), + (hCOMMANDS, UI.CmdDefs, GetCommandTable()), + (hINTVBLS, UI.IntVbls, GetIntVars()), + (hOPTVBLS, UI.OptVbls, GetOptions()), + (hKEYS, UI.Keys, GetKeyBindings()), + (hDIRSC, UI.DirSCs, GetDirShortcuts())): + + mvbl.delete(0,END) + + # Indicated if there is nothing to display for this class of help + if not mlist: + mvbl.add_command(label=hNONE % mname, command=None, foreground=HFCOLOR, background=HBCOLOR, + font=(HFNAME, HFSZ, HFWT)) + + # Load the help class with relevant information + else: + for l in mlist: + mvbl.add_command(label=l, command=None, foreground=HFCOLOR, background=HBCOLOR, font=(HFNAME, HFSZ, HFWT)) + + UI.HelpBtn.menu.add_cascade(label=mname, menu=mvbl) + + # Setup the About item + + UI.HelpBtn.menu.add_command(label=hABOUT, command=lambda title=hABOUT, text=ABOUT : showinfo(title, text)) + + # Enable the menu content + + UI.HelpBtn['menu'] = UI.HelpBtn.menu + UI.HelpBtn.config(state=NORMAL) + +# End of 'SetupGUI()' + + +##### # Strip Trailing Path Separator ##### @@ -1039,6 +1129,12 @@ # Bind handler to invoke Clear Command History self.DirList.bind(self.KeyBindings["CLRHIST"], ClearHistory) + # Bind handler to invoke Decrement Font Size + self.DirList.bind(self.KeyBindings["FONTDECR"], FontDecr) + + # Bind handler to invoke Increment Font Size + self.DirList.bind(self.KeyBindings["FONTINCR"], FontIncr) + # Bind handler to invoke Context Menu self.DirList.bind(self.KeyBindings["MOUSECTX"], MouseClick) @@ -1395,6 +1491,38 @@ ##### +# Decrement Font Size +##### + +def FontDecr(event): + global FSZ, MFSZ, HFSZ + + FSZ -= 1 + MFSZ -= 1 + HFSZ -= 1 + + SetupGUI() + +# End of 'FontDecr()' + + +##### +# Increment Font Size +##### + +def FontIncr(event): + global FSZ, MFSZ, HFSZ + + FSZ += 1 + MFSZ += 1 + HFSZ += 1 + + SetupGUI() + +# End of 'FontIncr()' + + +##### # Event Handler: Individual Keystrokes ##### @@ -2602,84 +2730,12 @@ ##### def ProcessOptions(): - global UI - - # Start in detailed mode unless details are inhibited - UI.SetDetailedView(~NODETAILS) - # 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.HelpBtn): - i.config(foreground=MFCOLOR, background=MBCOLOR, font=(MFNAME, MFSZ, MFWT)) - i.menu.config(foreground=MFCOLOR, background=MBCOLOR, font=(MFNAME, MFSZ, MFWT)) - - # Set Menu Bar background to match buttons - UI.mBar.config(background=MBARCOL) - - UI.DirList.config(font=(FNAME, FSZ, FWT), - foreground=FCOLOR, background=BCOLOR, - height=HEIGHT, width=WIDTH) - - # Make sure menus conform to max lengths (which may have changed). - - UpdateMenu(UI.DirBtn, UI.AllDirs, MAXDIR, MAXDIRBUF, LoadDirList, sort=TRUE) - UpdateMenu(UI.HistBtn, UI.CmdHist, MAXHIST, MAXHISTBUF, KeyRunCommand, fakeevent=TRUE) - ##### - # Initialize Help Menu with latest information + # Setup The GUI Visual Parameters, Menus, & Help Information ##### - # Clear out existing content - - UI.HelpBtn.config(state=DISABLED) - UI.HelpBtn.menu.delete(0,END) - - - # Update the cascading submenus - # We iterate across tuples of (Menu Name, Menu Variable, List Of Items) - - for mname, mvbl, mlist in ((hUSERVBLS, UI.UserVbls, GetUserVbls()), - (hCOMMANDS, UI.CmdDefs, GetCommandTable()), - (hINTVBLS, UI.IntVbls, GetIntVars()), - (hOPTVBLS, UI.OptVbls, GetOptions()), - (hKEYS, UI.Keys, GetKeyBindings()), - (hDIRSC, UI.DirSCs, GetDirShortcuts())): - - mvbl.delete(0,END) - - # Indicated if there is nothing to display for this class of help - if not mlist: - mvbl.add_command(label=hNONE % mname, command=None, foreground=HFCOLOR, background=HBCOLOR, - font=(HFNAME, HFSZ, HFWT)) - - # Load the help class with relevant information - else: - for l in mlist: - mvbl.add_command(label=l, command=None, foreground=HFCOLOR, background=HBCOLOR, font=(HFNAME, HFSZ, HFWT)) - - UI.HelpBtn.menu.add_cascade(label=mname, menu=mvbl) - - # Setup the About item - - UI.HelpBtn.menu.add_command(label=hABOUT, command=lambda title=hABOUT, text=ABOUT : showinfo(title, text)) - - # Enable the menu content - - UI.HelpBtn['menu'] = UI.HelpBtn.menu - UI.HelpBtn.config(state=NORMAL) + SetupGUI() ##### # Reflect Our Changes In The Interface