| SPECFE: a User Friendly Front End to Spec | ||
|---|---|---|
| <<< Previous | Customization of Specfe | Next >>> |
specfe looks for files called "user.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 which will be executed immediately.
At the time they are executed, the specfe user interface will have been created, but spec will not yet have been launched. You can add extra buttons and other interface elements using the code in user.tcl. Be careful though, your code will execute within the specfe application so it is advisable to have some idea of the internal organization of the specfe widgets. Some examples may be helpful.
The buttons in the specfe main window are contained in the .buttons widget. To add a new button we must create the button as a subwidget of .buttons and then insert it into the row of buttons. The buttons are managed using the 'grid' geometry manager so we must insert the new button after the existing ones.
button .buttons.userbutton -text "Print 42" -command [list spec_command "print 42"] grid configure .buttons.userbutton -row 0 -column [lindex [grid size .buttons] 0] -sticky nsew |
The 'spec_command' procedure is defined within specfe and can be used to send a command to spec, it takes a single argument. '[grid size .buttons]' is used to find out how many buttons are already on the specfe toolbar so that the new button can be placed after the existing buttons. '-sticky nsew' is used so that the button will expand to fill the available space on the toolbar.
The menubar widget in specfe is called .menubar, and the individual menus are called .menubar.mFile, .menubar.mGraph, .menuBar.mScans and .menubar.mCommands. The Scans and Commands are updated automatically by specfe so you should probably not try to modify them in the user.tcl code.
To add a command to an existing menu you could do something like
.menubar.mGraph add command -label "Print 42" -command [list spec_command "print 42"] |
To add commands to a new menu you could do something like
menu .menubar.newMenu -tearoff 0 .menubar add cascade -label "NewMenu" -menu .menubar.newMenu .menubar.newMenu add command -label "Print 42" -command [list spec_command "print 42"] |
The main notebook widget is a 'tixNoteBook' widget called .graphs. You can add extra pages to the notebook with the 'add' widget command. The existing pages are named graph1, graph2, graph3, graph4, tweaker, textview, scanlist, exafs and powder.
To add a new graph page to the notebook you could do something like
set graph5 [.graphs add graph5 -label "Graph 5"] new_graph $graph5.graph "Graph 5" grid $graph5.graph -sticky nsew grid columnconfigure $graph5 0 -weight 1 grid rowconfigure $graph5 0 -weight 1 |
which uses an internal specfe routine 'new_graph' to create and initialize a specfe graph on the new page.
| <<< Previous | Home | Next >>> |
| Customization of Specfe | Up | Troubleshooting |