![]() |
CCP4i: Graphical User Interface |
Documentation for Programmers | |
SelectFile |
![]() ![]() ![]() |
SelectFile - Present user with file selection window.
SelectFile fileout
Optional Arguments:
-title title_text
-unknown
-filter filter
-default filename
-defdir directory_alias
-format file_format
-parent parent_window
-directory
-custom custom_params custom_script
-filetype ...
-view
-return params
Present the user with a file selection window and return the selected file as fileout. Return a value of 1 if a file selection is successful or 0 if the user fails to select a file. The default title for the file selection window is "File Selection" but this should be made more specific using the -title argument. SelectFile will expect the user to select an existing file unless the command -unknown is used to indicate that the name for a new file is expected. The -filter argument is usually used with a filter to select all files of a given extension (e.g. "*.mtz").
The contents of the file selection window can be initialised. By default the contents of the current directory (i.e. the directory in which the user started CCP4i) are displayed. The argument -defdir with a directory_alias will start the file selection window in the directory of the directory_alias. It is also possible to set an initial default value for the selected file or directory with the default argument and the name of the file or directory filename.
By default the file selection window does not have any option to view the selected file. If the -format argument is used with the expected format of the selected file file_format, then a 'View' button will appear, and if the user clicks on this button they will get a preview of the file using the FileViewer appropriate for the file format. The file formats are defined in the $CCP4I_top/ec/types.def file which is described in more detail here.
The -parent argument is used to input the id of the parent window parent_window of the file select window. If the user closes the parent window then the file select window will also be closed.
There are additional arguments to SelectFile but these are used in very specific parts of the interface and are unlikely to be generally useful.
Select directories rather than files.
custom_params is a Tcl list of parameter names which will be defined when the file selection window is created. custom_script is a Tcl script which will be evaluated when the window is drawn (most probably instructions to add extra lines within the file selection window). When the user selects okay, the values of the parameters in custom_params are Tcl list-appended to the selected filename and returned to the calling procedure.
This option is currently undocumented - please see the SelectFile source code.
The file selection window will include an option to select an appropriate viewer, which will be used to display the selected file.
Specify a list of values to be returned, in addition to the selected filename. params is a Tcl list which can consist of any of the following items: fullpath (append the full path name of the selection), dir (the directory name of the selection), filename (the filename of the selection), filetype (the filetype as defined in types.def), defdir (the directory alias), viewer (the selected viewer, or blank if not applicable), filter (the filename filter used in the selection).