Google

CCP4i Documentation for Programmers: Core Documentation

Contents

Creating Windows (src/window.tcl)

Creating Windows

These are general window drawing procedures. Some procedures which are specific to drawing task windows are in taskwindows.tcl and some procedures which will draw one simple utitility windo are defined in util_windows.tcl.

All of the 'standard' windows in CCP4i are created with some standard \procedures:

OpenWindow: creates the shell of a window

CreateFrame: called after OpenWindow to create the basic internal folder structure and (very important) to attach an array to the window

CreateTaskWindow: Does everything OpenWindow and CreateFrame do plus creating some standard action buttons and titled folders.

The array which is attached to the window contains elements which are associated with the various widgets on the window and contain the currently entered or selected values for the parameters. These elements of the \array correspond to the parameters found in the def file for a task window or which must be defined by the DefineVariable command for use with CreateFrame. There are also elements of the array which perform a control function for things like the message line, the toggleable folders etc.. The elements have names which begin with uppercase e.g. PARAM_FRAME_nn.

Many precedures require the name of the data array as an argument -almost always referred to as arrayname. Some routines (e.g. CreateLine) do not require the array name to be input but get it from a saved 'system' variable which has been set by CreateFrame or CreateTaskWindow. This system variable can only be reliably used while the window is being initially defined. Any command which might be issued at a later time (after the user might have opened another window and the system variable being changed) must explicitly input the array name.

OpenWindow Open a graphical window

Argument list: <w> <title> <icon_name> <args>

This will open a window with a message bar and Help button but withoutthe folder structure or default action buttons of the task window opened byCreatetaskWindow. This procedure is useful for creating more customised graphics windows and is used mostly by the 'core' ccp4i.

The window does not absolutely need to have an associated data array but will need to have an array defined if it is to support the message line.

See also OpenGridWindow

w Name of toplevel window. If this window exists the procedure does nothing.

title Title to appear at top of window

icon_name Short title to appear if the window is iconised

-help help_file

Enter the name of a help file to be attached to the window help button

-target help_target

Set target in the help file to help_target

-message arrayname

Display an message line and use the standard elements of the array arrayname to contain the required message text.

-class class

Enter a class definition for the Tk toplevel command NOT USED

-nomessage REDUNDANT

-resizeable

The window will be resizable by the user

-parent arrayname

Arrayname is the data array for a 'parent' window. If the parent window is closed then its children will also be closed

OpenGridWindow Similar to OpenWindow but uses grid geometry manager

Argument list: <arrayname> <w> <title> <icon_name> <args>

When the child frames are arranged using the grid geometry manager it seems to be necessary to use grid all the way through the window definition. This procedure is used for customised window such as the file browser and sketcher rather than being a proper API.

The window is automatically created with a message bar and buttons frame and two additional frames called $w.main and $w.utils

arrayname Name of data array

w Name of toplevel window. If this window exists the procedure does nothing.

title Title to appear at top of window

icon_name Short title to appear if the window is iconised

-help help_file

Enter the name of a help file to be attached to the window help button

-target help_target

Set target in the help file to help_target

-class class

Enter a class definition for the Tk toplevel command NOT USED

-menu

Create a pull-down menu frame

CloseWindow Close a window opened by OpenWindow, OpenGridWindow or OpenTaskWindow

Argument list: <arrayname> <args>

arrayname Name od data array for the window

-window window

Set the window id (the Tk id) to override the default array(WINDOW)

-unset

Unset the whole of array

CreateFrame Set up a frame structure (i.e. folders) in a window opened by OpenWindow

Argument list: <w> <arrayname> <args>

To support the folder structure there must definitely be a data array associated with the window to contain the control parameters for the folders. By default the window will have a vertical scroll bar.

w The window id (a Tk id)

arrayname The data array for the window

-noscroll

Do not create a scroll bar.

CloseFrame End the definition of a frame.

Argument list: None

This procedure calls update_main_scroll to set the final size of the scrollable frame and run_update_script which tidies up extending frames.

OpenFolder Begin the definition of a folder in a task window

Argument list: <frame> <args>

See the CCP4i Programmers Documentation

update_folder Update visibility of folder dependent on protocol defined by OpenFolder

Argument list: <folder> <arrayname> <element> <args>

NB this procedure is called from the 'trace variable' function and has three redundant arguments appended to args

folder The folder id

arrayname The name of the task array

element The array element which controls the visibility of the folder

args The arguments input to OpenFolder and defined in:

See the CCP4i Programmers Documentation

update_folder_display Switch on or off the display of folders dependendent on the value of the switch parameter

Argument list: <frame> <arrayname> <mode>

frame The number of a folder or 'all'

arrayname Name of data array

mode Optional If mode=view then scroll task window so the opened folder is visible (but this may not be functional).

OpenSubFrame Open a sub frame within the context of OpenWindow/CreateFrame or CreateTaskWindow

Argument list: <framein> <args>

See CCP4I Programmers Documentation

CloseSubFrame Close a sub frame

Argument list: None

See CCP4I Programmers Documentation

toggle_frame_display Set up a trace command for handler controlling visibility of a line or subframe

Argument list: <line> <element> <hitstate> <hitlist> <table_row> <-1>

line Tk id of the line or frame

element Array element controlling line/frame visibility

hitstate Visibility state ('open' or 'hide') if value of element matches any value in hitlist

hitlist Tcl list of possible values for the control parameter

update_frame_display Handler controlling visibility of a line or subframe

Argument list: <line> <arrayname> <element> <hitlist> <hitstate> <args>

Called when user changed value of the control parameter

line Tk id of the line or frame

arrayname name of data array

element Array element controlling line/frame visibility

hitstate Visibility state ('open' or 'hide') if value of element matches any value in hitlist

hitlist Tcl list of possible values for the control parameter

update_table_row Toggle the display of a line in the table dependent on value of some varaible

Argument list: <table> <arrayname> <element> <hitlist> <hitstate> <\>

This proc is equivalent to update_frame_display but for rows in a table and is called when the variable is changed. The row is made invisible by setting the height to zero.

table Tk id of the table

arrayname name of data array

element Array element controlling line/frame visibility

hitstate Visibility state ('open' or 'hide') if value of element matches any value in hitlist

hitlist Tcl list of possible values for the control parameter

table_row The number of the row in the table (first row = 0)

height The normal height of the row when it is displayed

scrolled_frame Create a scrollable frame

Argument list: <w> <contents>

The mechanism for creating a scrolling frame is devious. This procedure will create the basic scrollable frame and scroll bar and will then create the required contents of the scrollable frame by evaluating the script which is passed into this procedure as a block of text. The script is actually evaluated in the variable context one level up by using the uplevel command.

This is a very important procedure used by all windows with scroll bars.

w The window id (a Tk id)

contents The text for a script to define the contents of the frame.

update_main_scroll Update the scrollable extent of a task window.

Argument list: <frame> <args>

The mechanism controlling scrolling needs to know the extent of the scrollable frame in the task window. This update is slow and is done only if the number of lines displayed in a task window has changed. If the sytem parameter block_scroll_update is set to 1 (true) then update_main_scroll does nothing. This blocking mechanism is used to prevent any unnecessary and time consuming update of the scrollable extent while the task window is initially being drawn.

frame The Tk frame id of any frame or widget within the task window.

UnsetArrayExtras Delete the 'extra' elements from a task window array

Argument list: <arrayname>

The extra eelments control the display of extending frames etc.in a task window. If a task window is deleted it is safer to delete these eelments before possibly redrawing the task window again.

arrayname Name of task window array

The array has already been tied to an interface and is probably going to be tied to a new interface. Variables which have a trace on them are listed in TRACE_LIST. These traces must be delted to avoid attempts to access widgets that no longer exist.

arrayname The name of an array

run_update_script After defining a new window tidy up the extending frames

Argument list: <arrayname>

The array element UPDATE_SCRIPTS may contain the text for some commands that extending frames require to be run after the rest of the windows are defined.

arrayname The data array for the window

GetNewWindowName Return a unique name for an array root_$n

Argument list: <root>

Root name for an array

Help, Message Line and Wait Commands

SetProgramHelpFile Set the name of the help file for the current window

Argument list: <program_name>

See CCP4i Programmers Documentation

The file name set using this procedure is used for all subsequent 'help' commands in the CreateLine procedure. If a task interface requires access to more than one help file then this procedure can be called multiple times to derefine the default help file.

program_name Usually just the name of a ccp4 program which will be assumed to have a help file in {$CCP4/html.} If this is not the case then the full path name of the help file should be given.

KeywordHelp Open a web browser to display a help document.

Argument list: <help_file> <help_target>

help_file Name of html file ot display

help_target Optional target within help file

SetMessage Bind cursor entering a widget to putting text in the message line

Argument list: <arrayname> <w> <m>

This supports the usual behavior that when curson enters a widget field the a short message describing that widget appears in the message line. In the long term this could be reimplemented as a bubble help.

arrayname Name of task interface array

w The id of a widget within the task window

m The text message to be displayed

set_message Display the given text in the message line

Argument list: <arrayname> <m> <args>

arrayname Name of task interface array

m The text message to be displayed

-block

Block any subsequent attempt to set the message until the -unblock option is used

-unblock

Unset any block on updating the message line

PleaseWait Display a 'Please wait' message

Argument list: <message>

See CCP4I Programmers Documentation

TkBusy' Iteratively set the cursor for all child windows to a watch/arrow

Argument list: <w> <d>

This function should not be used directly - use TkBusy

w The id for a window

d If false (0) set cursor to watch, if true (1) then reset cursor to arrow

TkBusy Set the cursor style for a window and all of it's children

Argument list: <w> <d> <0>

A watch cursor is used to indicate that the process is busy.

w The id for a window

d Optional, default 0. If false (0) set cursor to watch, if true (1) then reset cursor to arrow

File Selection Widgets

CreateInputFileLine Draw a line to select an input file

Argument list: <linein> <message> <label>

See the CCP4i Programmers Documentation

CreateOutputFileLine Draw a line to select an output file

Argument list: <linein> <message> <label> <fileout> <fileout_dir> <args>

See the CCP4i Programmers Documentation

FileViewer0 Extracts file name from a data array and passes to FileViewer

Argument list: <arrayname> <fileVar>

When the file viewer functionality is part of a callback, attached to a button (eg the 'Browse' button), then it is necessary to extract the name of the file from data array at the time the command is issued.

arrayname The data array for the window

fileVar The element of the array containing the file name

FileDialog Open a file selection dialog box associated with one file input line

Argument list: <openmode> <arrayname> <fileVar> <dirVar>

This uses the SelectFile procedure to provide the file selection dialog but also ensure that any selection on the file input line is passed to SelectFile and that the returned selection is put into the correct variable

openmode Should be 'open' for an input file or 'save' for an output file.#d_arg arrayname Name of task interface array

fileVar The name of the element in the array containing the file name

dirVar The name of the element in the array containing the directory alias

DirBrowser Present a 'file' browser for user to select a directory

Argument list: <arrayname> <arrayindex>

This assumes that the there is an text input widget for the directory path in a task interface and this procedure is called if the user clicks a 'Browse' button.

arrayname Name of task interface array

arrayindex Name of an element in the array which contains the directory name

CheckFileInput Check user input to file selection and return 1 if OK, 0 otherwise

Argument list: <arrayname> <fileVar> <mode> <dirVar> <args>

The user input of a file name is OK if an input file exists or an output file does not exist. For input files the procedure will attempt file name completion- e.g. adding an extension to a file name.

arrayname Name of task interface array

fileVar Name of an element in the array containing the file name

mode Should be 'open' for an input file or 'save' for an output file

dirVar Name of an element in the array containing the directory alias

-notoblig

Entering a file name is not obligatory so field will not have a contrast colour if it is left blank

-ext ext

Enter a file extension to use in file name completion

-title title

If attempted file name completion finds several files which are consistent with input then present user with list to select correct file.The title is used as a title for the selection dialog box.

ResolveUnixFileSymbols Interpret tilda or environment variable, or a relative path

Argument list: <path> <retpathVar>

The input to this procedure is is the first component of a file name. The procudure will return the full path name for this compenent. The return status is 1 = substitution successful, 0 = no substitution necessary or -1 = error in input

path Input first component of a file path name

retpathVar Output the full expansion of the input path.

IsPathADefaultDir Check if explicitly entered path corresponds to a project or aliased directory.

Argument list: <path> <aliasVar>

The user might type in a full path name rather than use the project or aliases. It is easier for ccp4i to keep track of files if the project or alias \is used so test any input full path and convert to a project/alias if possible.

path Full path name for file

aliasVar Returned project/alias.

CheckDirInput Validate user input of directory path

Argument list: <arrayname> <dir>

The procedure will handle input of ~ or environment variable

The widget for the directory input is updated with status colour depending on the validity of the user input.

arrayname Name of data array

dir Array element containing directory path

update_default_dir Update the path to file name in file selection line when user changes default directory

Argument list: <mode> <arrayname> <dir> <file>

mode REDUNDANT

arrayname Name of data array

dir Array element containing directory alias

file Array element containing file name

MoveFileNameLeft For long file name move position of file name in widget

Argument list: <arrayname> <file>

arrayname Name of data array

file Array element containing file name

UpdateOutputFilename Derive an output file name from an input file name

Argument list: <arrayname> <input_fileVar> <output_dir>

arrayname Name of data array

input_fileVar Name of array element containing the input file name

output_dir Name of array element containing output directory alias

output_file Name of array element containing output filename

output_ext An extension to the filename root (usually _taskname) note this is not the usually meaning of file extension

-in

The 'output' file is actually an input file - do file validation as for an input file.

add_file_command Bind a command to be issued after user has selected a file

Argument list: <linelist> <cmd>

It's tricky to know when the user has finished entering a file name and we don't want to bind commands (which may be slow) to events such as one keyboard stroke cos liable to be slow. Compromise is to bind commands to user hitting Return or Tab or releasing middle mouse (ie. pasting).

linelist A Tcl list of Create*putLine lines to have bound command

cmd Text script of command to be bound

SetParamFromFile Handler for the -setfileparam argument to CreateInputLine

Argument list: <paramtype> <arrayname> <format> <filename> <element>

This is called after user has selected an input file. The file can be MTZ, map or pdb format. The GetParamFromFile procedure is called to get the data from the file and this procedure puts the data into the array element and updates the validity status for the element.

paramtype The name of the type of data - corresponding to element in *_file_data array

arrayname Name of the task array

format The file format (MTZ/PDB/MAP)

filename The array element containing the input file name

element The name of the element to be assigned a value

GetParamFromFile Get specified type of data from a specified file header

Argument list: <format> <file> <param> <datain>

format The file format (MTZ/PDB/MAP)

file The full path input file name

param The name of the type of data - corresponding to element in *_file_data array

datain Output. The returned data value

The Generic Line Widget

CreateLine Draw a line in a window

Argument list: <linein> <args>

See the CCP4i Programmers Documentation

CreateLineTemplate Define a template for the layout of a line

Argument list: <name> <xpos>

See the CCP4i Programmers Documentation

PackByTemplate Apply the template defined by CreateLineTemplate to pack a line

Argument list: <line> <pack_template>

This procedure called by CreateLine for any line with command 'format template'. The procedure uses the Tk place command (rather than pack) to set the position of each widget on a line.

line The Tk id for the line

pack_template The name of the template to apply

UpdateDependentParams Callback afer user selects item from menu update the array element

Argument list: <selection> <arrayname> <param0> <args>

There is a 'problem' with Tk that when a user selects the item from a menu the data in the array element associated with the menubutton is not updated. The menubutton argument -textvariable might look like it will do the trick but there is an issue of which context the variable is defined in (i.e. in the context of a procedure or the global context).

selection The text of the selected menu item

arrayname Name of data array

param0 The name of the array element associated with the menubutton

initialise_menu Create a menu or reinitiallise an existing one

Argument list: <field>

This procedure used to support variable menus and CreateLabin (which is a special cas of a variable menu)

field The menubutton widget

UpdateVarLabel Update a variable label to an explicitly entered value

Argument list: <arrayname> <var> <value>

arrayname Name of data array

var Name of array element associated with the variable label widget

value New value for variable label

update_varlabel Update a variable label when the associated variable is changed

Argument list: <arrayname> <arrayindex> <widget_name> <n1> <n2> <op>

The Tcl trace command is used to call this procedure whenever the associated variable is changed.

arrayname Name of data array

arrayindex Name of array element containing the variable text for the label

widget_name Name of the widget (Tk id) to be updated

n1,n2,op Additional arguments added by the trace command

add_command Bind a command to a widget which may be a menu or an entry widget

Argument list: <field> <cmd>

The command will be issued when the user changes the selected menu item or hits Return key or moves focus out of the entry widget

This procedure needs to check the existing command string and append to it.

field The Tk id for the widget

cmd The command to be bound

paste_into_entries Paste into multiple fields

Argument list: <arrayname> <line> <ientry>

See User Documentation on Cut-n-Paste

arrayname Name of data array

line The Tk id of the selected line

ientry The number of the selected entry field (n_atom in name)

continue_paste Handler for user input for paste GUI

Argument list: <arrayname> <mode>

arrayname Name of data array

mode User's input of 'continue' mode

toggle_on Handler to toggle on a checkbutton when user inputs anywhere on a line

Argument list: <arrayname> <toggleonvar>

Handles the -toggleon option in CreateLine

arrayname Name of data array

toggleonvar Name of element in array to be toggled on

check_input Check entry widget input is consistent with data type

Argument list: <arrayname> <arrayindex> <format> <oblig> <0>

Checking is not very strict - for numerical input the data type defines integer/real and possible range. This procedure will try to correct poor input and will set the widget to the warning colour if input is wrong.

arrayname Name of data array

arrayindex Name of element in array

format Optional data type for the array element

oblig Optional 1=some data input is obligatory

set_field_colour Set the colour of an input widget dependent on validity of user input

Argument list: <arrayname> <arrayindex> <status>

arrayname Name of data array

arrayindex Name of element in array contaiining variable

status validity of user input 1=valid 0=invalid

Other Complex Widgets

CreateButton Create an action button in the 'button' frame of a window created by 'CreateFrame'

Argument list: <w> <name> <text> <command> <args>

w The window id (a Tk id)

name The button name (appended to the Tk widget id)

text Text to appear on button

command The command to be bound to the button

-message message

help message to associate with button

-default

undocumented

CreateText Create a Tk text widget, optionally scrollable.

Argument list: <textframeVar> <stuff> <args>

NOTE: This procedure needs an extra option to allow the user to edit the text. The text probably ought to be associated with an array element (i.e. treated like any other widget) but there is question of when to update the array parameter.

And then should be fully documented API

textframeVar Returned Tk text widget id

stuff Text to enter in the text widget

-scroll

Make widget vertically scrollable

-height height

Height of widget in number of text lines

-arguments arguments

Arguments to configure the text widget (i.e. valid Tk arguments)

AppendTextWindow Append text to CreateText widget

Argument list: <w> <text> <args>

w Tk id of the text widget

text Text to append to widget

-init

Reinitialise the widget (i.e. delete any existing text)

break_menu_column Internal procedure to set the -columnbreak value for items in a menu

Argument list: <counterVar> <column_length>

When invoked this procedure increments the counter for the number of items in the current menu column, if this exceeds the number in column_length then the counter is reset and 1 is returned (indicating that the current item should appear at the head of a new column); otherwise 0 is returned (indicating that the item should appear underneath the previous item in the same column).

counterVar Name of a counting variable which must be set to zero in the calling procedure for each menu

column_length The maximum number of items which can appear in each column of the menu

Task Window Utilities (src/taskwindow.tcl)

Task Window Utilities (src/taskwindow.tcl)

Utitlities specific to drawing task windows. Complements the utilities in windows.tcl which are more generic

RunTask Initialise parameters for task and draw task window

Argument list: <taskname> <args>

This procedure is called when the user clicks on a task in the modules and tasks menu. It is also called from other context when a task window is to be drawn.

This procedure initialises parameters from the tasks/taskname.def file \sources the taskname.tcl file and runs the foo_setup and foo_task_window procedures.

taskname The name of the task

-array arrayname

By default the task parameters are placed in an array called taskname.An alternative arrayname can be specified here.

-args argstring

The text string argstring appended as argument when calling the taskname_run procedure

-subsiduary subsiduary_taskname

Also open a subsiduary task window for subsiduary_taskname by calling RunTask

-def deffile

The default def file defining initial parameters is ccp4i/tasks/taskname.def and this file will always be read if it exists. The optional deffile will be read after this default df file.

-module module

By default the taskname.tcl file which defines the interface should be in ccp4i/tasks directory but if module is defined then it will be expected to be in ccp4i/module/ directory

draw_task_window Procedure called at end of RunTask to actually put the window on the screen

Argument list: <arrayname>

A major time consumer when drawing a task window is updating the scrollable frame controlled by the right hand side scroll bar. Updating this is done by update_main_scroll which is blocked while the window is been defined by taskname_run but is called after taskname_run is finished. #d_desc This procedure also deiconifies (i.e. displays the window on the screen)

CreateTaskWindow Called from taskname_run to define general appearance of task window

Argument list: <arrayname> <title> <icon_name> <frame_list> <args>

The arrayname and window id set up in the procedure are 'remembered' and used by subsequent calls to procedures such as CreateLine and CreateLabin. This procedure creates the folders for the task window and the action buttons.

Create task window taking task name and window name from array(TASK) and array(WINDOW)

arrayname Name of array containing parameters for task

title Title for task window

icon_name Name to appear on icinised window

folder_list A list of titles for folders in task window.

-action_buttons actions

Enter a list of action buttons to appear at the bottom of the widow. Options are: quit, reset, save, interactive, run, exit

-default_button default_action

Specify default_action as the default action button

-title

REDUNDANT

mode

REDUNDANT

-help_file help_file

The default help file is the file for the curr

DrawRunButton Draw the 'Run' button for task windows

Argument list: <wbuttons> <taskname> <w> <arrayname>

Draw the default run button with option to 'Run Remote' etc.

wbuttons The Tk frame id for the 'buttons' frame

taskname The task name

w The window id for the task window

arrayname Name of array containing parameters for task

UnsetProjectDefault Handle 'Unset Project default' option on Save or Restore menubutton

Argument list: <taskname> <w> <arrayname>

Give user option to delete current task defaults file or move it.The task project defaults are in the project directory CCP4_DATABASE/taskname.def

taskname The task name

w The window id for the task window

arrayname Name of array containing parameters for task

task_display_log Handle option to 'Display Log FIles' which is presented to user in 'task' mode of running ccp4i.

Argument list: <mode> <old_njobs>

mode May be 'list' or 'graphs' to display listing or log graphs.

old_njobs The number of jobs in the project database when the task is first created. Log files will only be displayed for jobs run subsequently.

redraw_task_window_title Redraw task window title with information on the origin of the initial parameters

Argument list: <arrayname>

arrayname The name of the task array

SaveUserDefinedDef Handler to save current parameters to user specified file

Argument list: <taskname> <arrayname> <field>

taskname The task name

arrayname Name of array containing parameters for task

field REDUNDANT

SaveProjectDef Handler to save current parameters to the user or the project default file.

Argument list: <taskname> <arrayname> <args>

By default this procedure saves the defaults for the project in the file project_directory/CCP4_DATABASE/taskname.def. Alternatively the 'user' defaults are saved in \$HOME/.CCP4/tasks/taskname.def. For some specific context the defaults may be saved to a file named defined in the task array as array(TASK_INPUT_DEF_FILE).

taskname The task name

arrayname Name of array containing parameters for task

-input

Save to file specified in array(TASK_INPUT_DEF_FILE) parameter

-user

Save to the 'user' defaults file

RedrawTaskWindow Redraw a task window from scratch after destroying existing window.

Argument list: <arrayname> <taskname>

After destrying the window the UnsetArrayExtras procedure removes all parameters in the array which are set up to control the window. These will be redefined when the window is redrawn.

ReCreateTaskWindow Load parameters from a def file and redraw the task window.

Argument list: <mode> <taskname> <w> <arrayname> <field>

After reloading parameters ther are often major changes in a window particularly in the number of extending frames and such like. It is easiest to redraw the window from scratch.

mode May be: JOB_NUMBER - prompt user for number of job from which parameters should be taken, USER_DEFINED - prompt user for def file name, CURRENT - reset from ccp4i default parameters, PROJECT - user parameters from the project default file.

taskname The task name

w The window id for the task window

arrayname Name of array containing parameters for task

DeleteTaskWindow Close a task window cleanly.

Argument list: <w> <arrayname> <taskname> <args>

If a taskname_close procedure exists then invoke it. Close the window and exit the interface if running in task mode.

w The window id for the task window

arrayname Name of array containing parameters for task

taskname The task name

SaveOnProgramExit Specify a task array which will be saved to a def file if the user exits the interface.

Argument list: <taskname> <arrayname>

Currently only used for mr_database.

arrayname Name of array containing parameters for task

taskname The task name

ExitInterface On exiting the interface save the status file and database file

Argument list: None

The system(TERMINATE) parameter is also reset so any procedure attached to the trace set by SaveOnProgramExit will be called.

CreateTitleLine Draw the title line which is standard at top of task window.

Argument list: <lineVar> <element>

lineVar Return the Tk frame id for the line

element The name of the parameter holding the title text.

check_title_line Hander when user enters title line test to remove 'bad' characters

Argument list: <arrayname> <element>

arrayname Name of array containing parameters for task

element The name of the parameter holding the title text.

WriteCredits Write author credits at bottom of task window

Argument list: <author_list> <args>

author_list A list of authors (NB should be Tcl list)

-link link_text link_target

A URL link to be added to credits line.

-label lab

Override the default text 'Program author'

Extending and Toggle Frames (src/exframe.tcl)

Extending and Toggle Frames

Read the Programmers Guide in main CCP4i Documentation.

See here.

The application programmer must provide a procedure which draws one 'row' of the extending or toggle frame (it may be more than one line). The name of this procedure is used as a reference for the parameters used to support this functionality (eg array(XF_INDEX_$def_proc0) where def_proc0 is the name of the defining procedure.

Either extending or toggle frames can have a 'child' extending frame nested inside the 'parent' frames. Many of the following procedures have an argument 'counter' which is the number of the parent frame for a child frame. This parameter is set to 0 if the frame is not nested within another frame.

CreateToggleFrame Create a toggle frame widget

Argument list: <indexVar> <def_proc0> <message> <title> <\>

A toggle frame widget differs from an extending frame in that each 'row'of the widget has a title line, similar to a folder title line, which may be clicked on to toggle the visibility of the 'row'.

indexVar Name of array element which is the counter for the number of open toggle frames.

def_proc0 Name of procedure which defines the content of one 'row'

message The message line associated with the 'Add whatever' button

title Title line for each toggle frame

add_text Text to appear in the 'Add whatever' button

indexed_parameters A list of all of the parameters which are referenced in the def_proc0 procedure

-depend dependent_frame

The name of the defining procedure for another toggle frame or extendinging frame widget which is incremented and edited in sync with the 'master' widget.

-child child_frame

The name of the defining procedure for another toggle frame or extending frame widget which is nested within this 'master' widget.

-noadd

Do not draw the Edit menu button and incement button for this widget. \This implies that this widget is dependent on another 'master' widget.

-edit_proc edit_procedure

When the user increments or edits the rows in the widget call the procedure edit_procedure. This procedure should be defined in the taskname.tcl file.

create_toggle_button Create the title line for the toggle frame

Argument list: <frame> <arrayname> <def_proc0> <counter> <c1>

frame Tk id for the toggle frame

arrayname Name of array

def_proc0 Name of procedure which defines the content of one 'row'

counter The 'row' number for the top level of nesting if this is a nested toggle frame (is 0 for a top level toggle frame).

c1 The 'row' number for the toggle frame.

SetToggleTitle Reset the title for a toggle frame

Argument list: <arrayname> <def_proc0> <c1> <title>

arrayname Name of array

def_proc0 Name of procedure which defines the content of one 'row'

c1 The 'row' number for the toggle frame

title New title for the toggle frame

update_subframe_display Update the visiblity of a toggle frame.

Argument list: <arrayname> <def_proc> <counter>

The visibility is dependent on the (FRAME_TOGGLE_....) parameter whichis controlled by the checkbutton on toggle frame title line.

arrayname Name of array

def_proc Name of procedure which defines the content of one 'row'

counter The 'row' number

indexVar Name of array element which is the counter for the number of open toggle frames.

def_proc0 Name of procedure which defines the content of one 'row'

message The message line associated with the 'Add whatever' button

add_text Text to appear in the 'Add whatever' button

indexed_parameters A list of all of the parameters which are referenced in the def_proc0 procedure

-depend dependent_frame

The name of the defining procedure for another extendinging frame widget which is incremented and edited in sync with the 'master' widget.

-child child_frame

The name of the defining procedure for another toggle frame or extending frame widget which is nested within this 'master' widget.

-noadd

Do not draw the Edit menu button and incement button for this widget. \This implies that this widget is dependent on another 'master' widget.

-edit_proc edit_procedure

When the user increments or edits the rows in the widget call the procedure edit_procedure. This procedure should be defined in the taskname.tcl file.

UpdateExtendingFrame Explicit programmer command to add or remove lines from an extending frame

Argument list: <def_proc0> <counter> <arrayname> <increment>

This is called after the programmer has explicitly changed the data for an extendining frame; for example after reading a file and loading default data. Note that the programmer is responsible for ensuring that the data is consistent - particularly that all parameters are set for every new line to be added. BUT the value of the index variable should NOT be updated.

def_proc0 Name of procedure which defines the content of one 'row'

counter For child frames: the frame number of the parent

arrayname The name of the array

increment The increment to the index variable (i.e. the number of lines ot be added or deleted).

set_open_frame Save information on the currently open frame (i.e. the one currently being drawn) to the systemvar array.

Argument list: <frame> <arrayname> <args>

This is used by CreateLine and other general widget drawing procedures.#d_arg frame Tk id of currently open frame

arrayname The name of the array

create_addline_command Draw the Edit menubutton and the increment button for toggle frames and extending frames.

Argument list: <lineVar> <message> <c1> <command> <def_proc0> <counter> <\>

lineVar Return the Tk id for te line

message The message line to be associated with the increment button

indexVar The name of the element containing the number of toggle/extending frame created.

command The appropriate command to update i.e. update_extendingframe0 or update_toggleframe0

def_proc0 Name of procedure which defines the content of one 'row'

counter For child frames the frame number of the parent

add_text The text which appears on the increment button

ifedit Logical value 0/1 which indicates if the 'Edit' menu should have { he} usual edit functions (or if =0, will just have 'Delete Last Line' option).

exframe_select Update the edit menu button after the user has selected a row for editting

Argument list: <mode> <arrayname> <def_proc0> <counter>

The menu options and the message line are updated when the user deletes or copies rows within the toggle or extending frames.

mode The eidt mode: quit/delete/copy

arrayname Name of array

def_proc0 Name of procedure which defines the content of one 'row'

counter For child frames the frame number of the parent

exframe_edit Handle mouse click tied to editting extending frames

Argument list: <arrayname> <def_proc0> <counter> <c1> <args>

User has clicked right mouse in a widget in an extending frame. If they are in edit mode then $array(XF_EDIT_$def_proc) specifies the edit mode.

arrayname Name of data array

def_proc0 Procedure name and name for this frame

counter For child frames the frame number of the parent

c1 The number of the selected row

-parent parent_def_proc

For child frame the name of the prcedure drawing the parent frame

-before

Insert before the selected row

delete_frame Delete a frame

Argument list: <arrayname> <def_proc0> <counter> <dframe>

In practice the graphical object corresponding to the highest number frame is deleted. The data is shuffled up to overwrite the the data in the frame selected for deletion.

arrayname Name of array

def_proc0 Name of procedure which defines the content of one 'row'

counter For child frames the frame number of the parent

dframe The number of the frame to be deleted

delete_frame_data Delete the data when a frame is deleted

Argument list: <arrayname> <def_proc0> <counter> <dframe>

arrayname Name of array

def_proc0 Name of procedure which defines the content of one 'row'

counter For child frames the frame number of the parent

dframe The number of the frame to be deleted

unset_child_indexed_params Unset the array variables for all the child frames of def_proc

Argument list: <arrayname> <def_proc0> <counter> <c1>

This procedure used to cleanup the child frames when the user has opted to delete the parent extending frame

arrayname Name of array

def_proc0 Name of procedure which defines the content of one 'row'

counter For child frames the frame number of the parent

c1 The number of rows in the child frame

copy_frame Copy the data in one row to another row

Argument list: <arrayname> <def_proc0> <counter> <fromin> <toin>

arrayname Name of the data array

def_proc0 Name of procedure which defines the content of one 'row'

counter The id of the parent frame if this is a child frame

fromin The source row

toin The target row (If = 0 append the data to the end of the extending frame)

copy_frame_c1 Copy parameters of a child frame from one parent (from) to another (to)

Argument list: <arrayname> <def_proc0> <from> <to>

arrayname Name of array

def_proc0 Name of procedure which defines the content of one 'row'

from Copy data from this parent frame

to Copy data to this parent frame

append_extend_frame Add another frame to the bottom of extending frame

Argument list: <arrayname> <def_proc0> <counter> <c1In>

arrayname Name of array

def_proc0 Name of procedure which defines the content of one 'row'

counter For child frames the frame number of the parent

c1in Optional parameter. If set is the number for the new frame to be draw. Other the new frame number is the current number of frames plus 1

append_toggle_frame Add another frame to the bottom of a toggle frame widget

Argument list: <arrayname> <def_proc0> <counter> <c1In>

arrayname Name of array

def_proc0 Name of procedure which defines the content of one 'row'

counter For child frames the frame number of the parent

c1in Optional parameter. If set is the number for the new frame to be draw. Other the new frame number is the current number of frames plus 1

append_frame_c1 Draw child frames when called from append_*_frame

Argument list: <arrayname> <def_proc0> <counter>

arrayname Name of array

def_proc0 Name of procedure which defines the content of one 'row'

bind_edit_select Add the edit function right-mouse button bindings

Argument list: <f> <arrayname> <def_proc0> <counter> <c1>

arrayname Name of array

def_proc0 Name of procedure which defines the content of one 'row'

counter The frame number of the parent

c1 The frame number of the child extending frame

SetIndexedParam Assign values to a group of indexed elements with the same index

Argument list: <arrayname> <varlist> <values> <c1> <c2>

This is called when an extra frame is added to an extending frame to initialise all the array elements in that frame. If an array element

arrayname Name of data array

varlist List of the root names for the array elements

values List of values for the array elements. Can be an empty string.

c1 The first index for the elements

c2 Optional. The second index for the elements

UnsetIndexedParam Unset the elements of array for a parameter, its data type and widget

Argument list: <arrayname> <varlist> <c1> <c2> <>

arrayname Name of data array

varlist List of elements in array

c1 The first index number

c2 The optional second index number

Using the BLT Table Widget

Using the BLT Table Widget

These functions require using bltwish rather than wish. They draw a table with edit menu button and increment button similar to extending frames but are more efficient at handling larger amounts of data. The data for the table must be in a separate array - see the description of CreateTable

CreateTable Create a table using the BLT table function

Argument list: <arrayname> <table_id> <dataVar> <data_spec> <f> <args>

This widget is created very differently to the extendinging frames and toggle frames but (for a consistent interface) has similar edit menu button and increment button at the bottom of the table. The table is designed \to have column titles but each eelment of the table is an entry widget and additional labels are not supported.

See the table by the side of the Monomer Library Sketcher window or the Edit Restriants in PDB window for examples.

arrayname Name of array

table_id A unique identifying name for the table

dataVar Array containing the tabulated data displayed in the table The data array is a 2-dimensional array with element names {$column_name,$ir} where {$column_name} is the name of the column and {$ir} is the row number.

data_spec A a specification of the table - a list with one list item for each column. Each list item is also a list with the items: 0 - name of data in the column 1 - column title 2 - data type if not represented as a simple entry widget 3 - width of entry widget (number of characters) 4 - default initial value 5 - message line describing the data in the column

f The Tk id of the frame in which to create the table

-scroll

Put the table inside a scrolling frame with a vertical scroll bar.

-noedit

Do not draw the edit menu button and increment button under the table

-nolabel

Do not draw column titles

-row row_procedure

Specify the procedure to draw one row of the table

CreateTableTitle Draw column titles in table

Argument list: <t> <column_titles>

t The Tk frame id for the table

column_titles The list of column titles

table_edit_buttons Draw the edit menu button and increment button under the table

Argument list: <arrayname> <table_id> <frame>

arrayname Name of array

table_id A unique identifying name for the table

frame The Tk frame id for the table buttons frame

TableDrawRow Draw one row of a table

Argument list: <arrayname> <table_id> <ir>

If the -row argument to CreateTable specified a procedure to draw a row then call that procedure with the arguments arrayname and ir (the row number). Otherwise draw a default format row using the information on data type and entry widget width provided as argument to CreateTable.

arrayname Name of array

table_id A unique identifying name for the table

ir The row number

TableAddRow Add an extra row to the table to support the edit functions

Argument list: <arrayname> <table_id> <row> <mode>

arrayname Name of array

table_id A unique identifying name for the table

row Add new row after row number row. row = end => append to end of table row = query => query user

mode Optional. If mode is copy then initialise the new row with data determined by the row argument: row = query => query user row = {[list} copy_from_row copy_to_row\]

TableDeleteRow Delete a row from the table

Argument list: <arrayname> <table_id> <ir>

arrayname Name of array

table_id A unique identifying name for the table

ir The number of the row to delete or ir = end => delete last row ir = query => query user

TableDeleteContents Delete the entire contents of the table but keep the column titles.

Argument list: <arrayname> <table_id>

arrayname Name of array

table_id A unique identifying name for the table

TableGetExtent Return the Cnumber of rows in the table

Argument list: <arrayname> <table_id>

arrayname Name of array

table_id A unique identifying name for the table

get_table_extent Return the Cnumber of rows in the table

Argument list: <t>

t The Tk id for the table

TableUpdateScroll Update the scrollable area of the table.

Argument list: <f>

Must be called after adding or deleting a row.

f The id of the Tk frame containing the table

Variable Menus (src/varmenu.tcl)

Variable Menus

This is the mechanism to handle menus whose menuitems may change during the lifetime of the window. For example in the AMoRe interface there is a menu to select a TEST_SPACE_GROUP which is must be one of the alternative \in the same Laue group as the space group of the input data. The appropriatemenu can only be set after the user has entered the input MTZ file whichprovides the input space group information. To implement this there are thefollowing definitions in the amore.def file:

TEST_SPACE_GROUP _laue_space_group ""

LAUE_SPGP_LIST _list_of_text ""

LAUE_SPGP_ALIAS _list_of_text ""

The TEST_SPACE_GROUP will be the test space group which the userwill select from a menu which is defined in amore_setup:

set typedef(_laue_space_group) { varmenu LAUE_SPGP_LIST LAUE_SPGP_ALIAS 8 }

Here the datatype _laue_space_group is defined as a variable menu which has the menuitems taken from the parameter LAUE_SPGP_LIST and the 'alias' of the menuitems taken from the parameter LAUE_SPGP_ALIAS. Both of theseparameters have been defined in the amore.def and are initially empty. Whenthe user selects an input MTZ file the procedure amore_set_test_space_group is called which finds the appropriate Laue space groups and loads them into the varaibles LAUE_SPGP_LIST and LAUE_ALIAS_LIST and then calls the procedure UpdateVariableMenu to update the variable.

In these handling procedures the datatype for the variable menu (e.g. LAUE_SPGP_LIST) in the above example) is referred to as the deflistVar.Note that is quite possible for thereto be multiple widget which have the same variable menu and a list of these is stored in array(DEPVARS_$deflistVar).

create_varmenu Called from CreateLine procedure to update array(DEPVARS_$deflistVar)

Argument list: <arrayname> <depvar>

array(DEPVARS_$deflistVar) is list of all variables which are attachedto created widgets which have list of possble values $deflistVar.

arrayname The name of the task array

depvar The name of the variable which associated which the widget which is been created.

UpdateVariableMenu Invoked by user to update the variable menu

Argument list: <arrayname> <mode> <nn> <deflistVar> <input> <\>

The input parameters aliaslistVar and alais are optional and notrequired if an alias parameter has not been defined.

arrayname The name of the task array

mode Can be 'initialise', 'append' or 'replace'

n The number of the menu item to be replaced in 'replace' mode

deflistVar Element of array containing the list of menu item

input input value(s) for deflistVar

aliaslistVar Element of array containing the aliases for menu items

alias input value(s) for aliaslistVar

update_varmenu Handler to update one item of variable menu

Argument list: <arrayname> <mode> <varmenu_element> <\>

This procedure is called by a trace mechanism if the user changes another text widget which defines an item on the variable menu.

arrayname The name of the task array

mode Expected to be replace

varmenu_element The number of the menu item to be replaced in 'replace' mode

varmenu_name Element of array containing the list of menu items

inputVar Element of array containing the new value for the replaced menu item

update_menu Called from UpdateVariableMenu to redraw the menu(s) associated with one variable.

Argument list: <arrayname> <element> <menu_listVar> <input_command>

Because each variable could potentially be attached to more than onewidget this procedure call update_menu0 which redraws each individual instanceof the menu.

arrayname The name of the task array

element The array element which has a variable menu widget

menu_listVar Element of array containing the list of menu items

input_command An additional command assciated with the menu

update_menu0 Update each individual instance of a variable menu

Argument list: <field> <arrayname> <element> <menu_list> <input_command>

field The widget name of the menu

arrayname The name of the task array

element The array element attached to the variable menu widget

menu_list The list of menu items

input_command Optional command to be bound to an menu selection