File dialogs

The file dialogs can be used to select a file for the open or save mode.

../../../../_images/File.png

Clicking the button opens the file dialog like

../../../../_images/FileDialogs.png

After closing the dialog, the selected file is displayed in the button.

Syntax

<Parameter>
<Name>ColorID</Name>
<Text>Color</Text>
<Value></Value>
<ValueType>String</ValueType>
<ValueDialog>xxxFileDialog</ValueDialog>
<FileFilter>pyv-files(pyv-files(*.pyv)|*.pyv|</FileFilter>
<FileExtension>pyv</FileExtension>
<DefaultDirectories>etc|std|usr|prj</DefaultDirectories>
</Parameter>

The following value dialog keywords are possible:

<ValueDialog>

<DefaultDirectories>

description

OpenFileDialog

yes

Display a file open dialog

SaveFileDialog

yes

Display a file save dialog

OpenFavoriteFileDialog

no, standard

Display a favorite file open dialog

SaveFavoriteFileDialog

no, standard

Display a favorite file save dialog

To filter the files displayed in the file dialog, the <FileFilter> tag can be used. The format of the filter must look like pyv-files(pyv-files(*.pyv)|*.pyv|. Multiple filter can be combined.

The default file extension can be set by the <FileExtension> tag.

If the button with the possibility to open default directories is to be added to the left side of the file dialog, the <DefaultDirectories> must be used. The following directories can be displayed

short cut

directory

etc

Standard directory

std

Office

usr

Private

prj

Current project

Optional tags

If the PythonPart should be localized, the following tag must be added

<TextId>1001</TextId>

Sometimes it’s useful to disable or hide the button depending on the value of another parameter. This is achieved by adding additional tags to the parameter or by defining functions in the py-file. See Enable and visible options

The persistent state of the parameter can be changed by adding

<Persistent></Persistent>

Example

The implementation of the xxxFileDialog value dialog is described in the example AllControls located in

..\etc\Examples\PythonParts\PaletteExamples\AllControls.pyp
..\etc\PythonPartsExampleScripts\PaletteExamples\AllControls.py