Wednesday, March 02, 2005

How to do a variable menu in CCP4i Tcl:

First, add a typedef for the new varmenu we are about to create:


set typedef(_input_columns) { varmenu INPUT_COLUMNS_LIST INPUT_COLUMNS_ALIAS 8 }



Then, add code to the place where you want to change the varmenu (for example, a subroutine like "add_an_input_column".


UpdateVariableMenu $arrayname initialise [llength $array(INPUT_COLUMNS_LIST,0)] INPUT_COLUMNS_LIST $columns INPUT_COLUMNS_ALIAS $columns


Then add code for INPUT_COLUMNS to your .def file:


INPUT_COLUMNS,0 _input_columns ""
INPUT_COLUMNS_LIST,0 _list_of_text {"test1" "test2" }
INPUT_COLUMNS_ALIAS,0 _list_of_text {"TESTT1" "TESTT2" }


Finally, create the widget as you would do so normally:
                                                                     
CreateLine line label "Input columns" widget INPUT_COLUMNS