Customization of Specfe

Specfe allows a modest amount of customization by the user. During the specfe application initialization there are two points at which user-defined tcl code may be run. The first point is specifically intended to allow the user to add extra command templates to the Commands menu while the second point is after the specfe user interface has been initialized, but just before spec is launched.

The customization code is called via the following tcl fragments in the specfe code:

      if {$runspec} {
        ...

        if {[file exists "~/.specfe/templates.tcl"]} {
          source "~/.specfe/templates.tcl"
        } 
      
        if {[file exists "templates.tcl"]} {
          source "templates.tcl"
        }
      }
    

and

	if {[file exists "~/.specfe/user.tcl"]} {
	  source "~/.specfe/user.tcl"
	}
	
	if {[file exists "user.tcl"]} {
	  source "user.tcl"
	}
      

Customizing the Command Templates

specfe looks for files called "templates.tcl" in both the "~/.specfe" directory and in the current working directory. If either of these files exist they are sourced. They should contain tcl commands to set elements of the 'templates' array. The commands menu is built by sorting the element names in alphabetic order and creating a command entry from each array element. The element should consist of a list of values:

	set templates(elemname) {
	  speccmd menuentry arg1 arg2 ... argn
	}
      

  1. speccmd is the name of the spec command to issue.

  2. menuentry is the text of the menu entry in the Commands

  3. arg1 describes the first argument of the spec command

  4. argn describes the nth argument of the spec command

Each argument is described by a list of four values and will become a single row in the resulting command dialog:

	  { label type prefname description }
	

  1. label is the dialog label for the argument

  2. type is the type of the argument (allowed values are number, string or motor).

  3. prefname is used to save values in the preferences file. The prefname should be a unique name within the arguments for the particular command.

  4. description is a longer description of the argument which will appear in the command dialog.

As an example, the template shown below is used to define a command template for the lup command:

	  set templates(lup) {
	    lup "Line-up scan (single motor, relative coordinates)"
	    { "Motor:" motor motor "Motor to scan.." }
	    { "Start:" number start "Start scan from..." }
	    { "Finish:" number finish "Finish scan at..." }
	    { "Intervals:" number intervals "Number of scan steps..." }
	    { "Time:" number time "Counting time..." }
	  }
	

This will generate the following command dialog:

Figure 1. lup scan dialog