Search documentation of wx

# View Source wxFileDialog (wx v2.4.2)

Functions for wxFileDialog class

This class represents the file chooser dialog.

The path and filename are distinct elements of a full file pathname. If path is ?wxEmptyString, the current directory will be used. If filename is ?wxEmptyString, no default filename will be supplied. The wildcard determines what files are displayed in the file selector, and file extension supplies a type extension for the required filename.

The typical usage for the open file dialog is:

The typical usage for the save file dialog is instead somewhat simpler:

Remark: All implementations of the `wxFileDialog` provide a wildcard filter. Typing a filename containing wildcards (, ?) in the filename text item, and clicking on Ok, will result in only those files matching the pattern being displayed. The wildcard may be a specification for multiple types of file with a description for each, such as: It must be noted that wildcard support in the native Motif file dialog is quite limited: only one file type is supported, and it is displayed without the descriptive test; "BMP files (.bmp)|.bmp" is displayed as ".bmp", and both "BMP files (.bmp)|.bmp|GIF files (.gif)|.gif" and "Image files|.bmp;.gif" are errors. On Mac macOS in the open file dialog the filter choice box is not shown by default. Instead all given wildcards are appplied at the same time: So in the above example all bmp, gif and png files are displayed. To enforce the display of the filter choice set the corresponding `wxSystemOptions` before calling the file open dialog: But in contrast to Windows and Unix, where the file type choice filters only the selected files, on Mac macOS even in this case the dialog shows all files matching all file types. The files which does not match the currently selected file type are greyed out and are not selectable.

Styles

This class supports the following styles:

See: Overview cmndlg, ?wxFileSelector()

This class is derived (and can use functions) from: `wxDialog` `wxTopLevelWindow` `wxWindow` `wxEvtHandler`

wxWidgets docs: wxFileDialog

# Summary

## Types

wxFileDialog()

## Functions

destroy(This)

Destructor.

getDirectory(This)

Returns the default directory.

getFilename(This)

Returns the default filename.

getFilenames(This)

Fills the array `filenames` with the names of the files chosen.

getFilterIndex(This)

Returns the index into the list of filters supplied, optionally, in the wildcard parameter.

getMessage(This)

Returns the message that will be displayed on the dialog.

getPath(This)

Returns the full path (directory and filename) of the selected file.

getPaths(This)

Fills the array `paths` with the full paths of the files chosen.

getWildcard(This)

Returns the file dialog wildcard.

new(Parent)
new/2

Constructor.

setDirectory(This, Directory)

Sets the default directory.

setFilename(This, Setfilename)

Sets the default filename.

setFilterIndex(This, FilterIndex)

Sets the default filter index, starting from zero.

setMessage(This, Message)

Sets the message that will be displayed on the dialog.

setPath(This, Path)

Sets the path (the combined directory and filename that will be returned when the dialog is dismissed).

setWildcard(This, WildCard)

Sets the wildcard, which can contain multiple file types, for example: "BMP files (.bmp)|.bmp|GIF files (.gif)|.gif".

# Types

Link to this type

# wxFileDialog()

View Source

    -type wxFileDialog() :: wx:wx_object().

# Functions

Link to this function

# destroy(This)

View Source

    -spec destroy(This :: wxFileDialog()) -> ok.

Destructor.

Link to this function

# getDirectory(This)

View Source

    -spec getDirectory(This) -> unicode:charlist() when This :: wxFileDialog().

Returns the default directory.

Link to this function

# getFilename(This)

View Source

    -spec getFilename(This) -> unicode:charlist() when This :: wxFileDialog().

Returns the default filename.

Note: This function can't be used with dialogs which have the `wxFD_MULTIPLE` style, use `getFilenames/1` instead.

Link to this function

# getFilenames(This)

View Source

    -spec getFilenames(This) -> [unicode:charlist()] when This :: wxFileDialog().

Fills the array `filenames` with the names of the files chosen.

This function should only be used with the dialogs which have `wxFD_MULTIPLE` style, use `getFilename/1` for the others.

Note that under Windows, if the user selects shortcuts, the filenames include paths, since the application cannot determine the full path of each referenced file by appending the directory containing the shortcuts to the filename.

Link to this function

# getFilterIndex(This)

View Source

    -spec getFilterIndex(This) -> integer() when This :: wxFileDialog().

Returns the index into the list of filters supplied, optionally, in the wildcard parameter.

Before the dialog is shown, this is the index which will be used when the dialog is first displayed.

After the dialog is shown, this is the index selected by the user.

Link to this function

# getMessage(This)

View Source

    -spec getMessage(This) -> unicode:charlist() when This :: wxFileDialog().

Returns the message that will be displayed on the dialog.

Link to this function

# getPath(This)

View Source

    -spec getPath(This) -> unicode:charlist() when This :: wxFileDialog().

Returns the full path (directory and filename) of the selected file.

Note: This function can't be used with dialogs which have the `wxFD_MULTIPLE` style, use `getPaths/1` instead.

Link to this function

# getPaths(This)

View Source

    -spec getPaths(This) -> [unicode:charlist()] when This :: wxFileDialog().

Fills the array `paths` with the full paths of the files chosen.

This function should only be used with the dialogs which have `wxFD_MULTIPLE` style, use `getPath/1` for the others.

Link to this function

# getWildcard(This)

View Source

    -spec getWildcard(This) -> unicode:charlist() when This :: wxFileDialog().

Returns the file dialog wildcard.

Link to this function

# new(Parent)

View Source

    -spec new(Parent) -> wxFileDialog() when Parent :: wxWindow:wxWindow().

Link to this function

# new/2

View Source

    -spec new(Parent, [Option]) -> wxFileDialog()
                 when
                     Parent :: wxWindow:wxWindow(),
                     Option ::
                         {message, unicode:chardata()} |
                         {defaultDir, unicode:chardata()} |
                         {defaultFile, unicode:chardata()} |
                         {wildCard, unicode:chardata()} |
                         {style, integer()} |
                         {pos, {X :: integer(), Y :: integer()}} |
                         {sz, {W :: integer(), H :: integer()}}.

Constructor.

Use `wxDialog:showModal/1` to show the dialog.

Link to this function

# setDirectory(This, Directory)

View Source

    -spec setDirectory(This, Directory) -> ok when This :: wxFileDialog(), Directory :: unicode:chardata().

Sets the default directory.

Link to this function

# setFilename(This, Setfilename)

View Source

    -spec setFilename(This, Setfilename) -> ok
                         when This :: wxFileDialog(), Setfilename :: unicode:chardata().

Sets the default filename.

In wxGTK this will have little effect unless a default directory has previously been set.

Link to this function

# setFilterIndex(This, FilterIndex)

View Source

    -spec setFilterIndex(This, FilterIndex) -> ok when This :: wxFileDialog(), FilterIndex :: integer().

Sets the default filter index, starting from zero.

Link to this function

# setMessage(This, Message)

View Source

    -spec setMessage(This, Message) -> ok when This :: wxFileDialog(), Message :: unicode:chardata().

Sets the message that will be displayed on the dialog.

Link to this function

# setPath(This, Path)

View Source

    -spec setPath(This, Path) -> ok when This :: wxFileDialog(), Path :: unicode:chardata().

Sets the path (the combined directory and filename that will be returned when the dialog is dismissed).

Link to this function

# setWildcard(This, WildCard)

View Source

    -spec setWildcard(This, WildCard) -> ok when This :: wxFileDialog(), WildCard :: unicode:chardata().

Sets the wildcard, which can contain multiple file types, for example: "BMP files (.bmp)|.bmp|GIF files (.gif)|.gif".

Note that the native Motif dialog has some limitations with respect to wildcards; see the Remarks section above.