For versions of Slicer starting with 2.0, new modules that are not part of the main Slicer code base are added to the directory slicer2/Modules. Instructions for building a custom module can be found in Modules/README.modules, and sample code can be found in slicer2/Modules/vtkCustomModule.
To ensure that the tcl files associated with the module are loaded during the GUI construction, follow the instructions in the README.txt file in the vtkCustomModule directory. If the renaming is done via the call to the vtkNameModule tcl script, your module will be registered with the Slicer base and will be initialized correctly. You must name your subdirectory in the Modules directory starting with the prefix vtk or it will not be automatically found at run time nor during auto compilation via the cmaker.tcl script.

New core modules are added to the code base in the directory slicer2/Base/tcl/tcl-modules. Inside this directory, there is an example file called Custom.tcl that explains in detail how to create your own core module. This should be avoided unless you are adding new functionality necessary to Slicer.

All files in the tcl-modules directory (generally referred to here as "modules") will automatically receive a button on Slicer's main menu. They will also be provided with a tab on the GUI.

To allow multiple users to develop their own modules on UNIX systems, Slicer will preferentially source modules in any local Modules/vtk* directories that it finds in the directory from which it was run, your home directory, or a user-designated Modules directory. Then Slicer will continue on to source the rest of the core tcl files and distributed Modules that it finds in the directory where it was installed.

   

Easy Development Tip

Run Slicer from inside your personal slicer2 directory and it will find your new modules. This is because Slicer will preferentially source Tcl files in your local Modules directory.
If you have set your HOME environment variable, Slicer will load custom modules from your ${HOME}/Modules directory as well. You can also set your SLICER_MODULES environment variable to point to more custom modules.