8.6. Tailoring the Folder GUI

In this section we will see how to extend the folder GUI. We will describe specifically:

Before getting down to the topics above, let's look at the mechanics of incorporating your changes into the GUI when SpecTcl starts. As we already know, the script SpecTclRC.tcl is sourced by SpecTcl as it starts. The initial version of this script comes with the skeleton files you copied when you started developing your Spectcl.

The folder GUI is started by this script via the following script command:


source $SpecTclHome/Script/newGui.tcl
            

Simply add your code to extend the GUI anywhere after this line of code in SpecTclRC.tcl. I recommend encapsulating that code into a separate script file, testing your extensions by sourcing them by hand, and then, when you are ready to go to production, adding source to your SpecTclRC.tcl to source your extension script.

8.6.1. Extending the main window menubar and menus

The main window of the folder GUI features a menubar. The menu bar is stocked with a set of menus that allow access to most of the GUI commands. The menubar is named .topmenu The menus it contains are named:

.topmenu.filemenu

Contains the File menu contents.

.topmenu.edit

Contains the Edit menu contents.

.topmenu.source

Contains the Data Source menu contents.

.topmenu.filter

Contains the Filters menu contents>

.topmenu.spectra

Contains the Spectra menu contents.

.topmenu.gate

Contains the Gates menu contents.

.topmenu.help

Contains the Help menu contents.

Menus can be added to the menubar between the Gates and the Help menus. Menus are added to the menubar by creating a menu that is a child of .topmenu and by adding a cascade element to .topmenu that has the menu as it's -menu.

The sample code below adds a new menu named Application that contains an item that clears a selected set of spectra using the code developed in the previous section:

Example 8-27. Adding a menu to the folder GUI menubar


                    
menu .toplevel.application
.toplevel.application add command -label {Clear selected spectra ...} \
                                  -command clearSelectedSpectra

.toplevel add cascade -label Application -menu .toplevel.application

                

Similarly, knowing the names of the menus the folder GUI creates allows us to add commands to the bottom of them. Adding a menu entry to the Spectra menu to clear a selection of spectra is done as follows:

Example 8-28. Extending an existing folder GUI menu


.toplevel.spectra add separator
.toplevel.spectra add command -label {Clear selected spectra...}  \
                              -command clearSelectedSpectra
                 

8.6.2. Extending the context menus

Context menus are the menus in the folder gui that pop up when you hold the right mouse button down over an item in the folder GUI's main window. The context menus are created by the folder GUI the first time they are needed, if they have not yet been built. Therefore, in order to extend a context menu, you will first have to create the context menu you want to extend and then add elements to it.

The following procedures create context menus in the folder gui:

createSpectrumFolderContextMenu

Creates the context menu for the spectrum folder. The menu is named: .spectrumfoldercontextmenu

createParameterFolderContextMenu

Creates the context menu that for the parameters folder. The menu is named: .parameterfoldercontextmenu

createGateFolderContextMenu

Creates the context menu for the Gates folder. The menu is named: .gatefoldercontextmenu

createVariableFolderContextMenu

Creates the context menu for the Variables folder. This menu is named: .variablefoldercontextmenu

createSpectrumContextMenu

Creates the context menu for individual spectra in the spectrum folder. This context menu is named: .parametercontextmenu

8.6.3. Using the folder browser in your own dialogs