************* wx.FileDialog ************* Inheritance diagram for `wx.FileDialog`: | .. inheritance-diagram:: wx.FileDialog | Description =========== This class represents the file chooser dialog. Pops up a file selector box. In Windows and GTK2.4+, this is the common file selector dialog. In X, this is a file selector box with somewhat less functionality. The path and filename are distinct elements of a full file pathname. If path is \"\", the current directory will be used. If filename is \"\", 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. Both the X and Windows versions implement 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:: "BMP and GIF files (*.bmp; *.gif)|*.bmp; *.gif | PNG files (*.png)| *.png" .. note:: It must be noted that wildcard support in the native Motif file dialog is quite limited: only one alternative 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. .. seealso:: `wx.FileSelector <../wx.Functions.html#FileSelector>`_ Derived From ^^^^^^^^^^^^^ * `wx.Dialog `_ * `wx.Window `_ * `wx.EvtHandler `_ * `wx.Object `_ Window Styles ^^^^^^^^^^^^^ ================================================== ================================================== Window Style Description ================================================== ================================================== ``wx.FD_DEFAULT_STYLE`` Equivalent to ``wx.FD_OPEN``. ``wx.FD_OPEN`` This is an open dialog; usually this means that the default button's label of the dialog is "Open". Cannot be combined with ``wx.FD_SAVE``. ``wx.FD_SAVE`` This is a save dialog; usually this means that the default button's label of the dialog is "Save". Cannot be combined with ``wx.FD_OPEN``. ``wx.FD_OVERWRITE_PROMPT`` For save dialog only: prompt for a confirmation if a file will be overwritten. ``wx.FD_FILE_MUST_EXIST`` For open dialog only: the user may only select files that actually exist. ``wx.FD_MULTIPLE`` For open dialog only: allows selecting multiple files. ``wx.FD_CHANGE_DIR`` Change the current working directory to the directory where the file(s) chosen by the user are. ``wx.FD_PREVIEW`` Show the preview of the selected files (currently only supported by wxGTK using GTK+ 2.4 or later). ================================================== ================================================== Methods Summary ^^^^^^^^^^^^^^^ * `__init__ <#__init__>`_ * `GetDirectory <#GetDirectory>`_ * `GetFilename <#GetFilename>`_ * `GetFilenames <#GetFilenames>`_ * `GetFilterIndex <#GetFilterIndex>`_ * `GetMessage <#GetMessage>`_ * `GetPath <#GetPath>`_ * `GetPaths <#GetPaths>`_ * `GetWildcard <#GetWildcard>`_ * `SetDirectory <#SetDirectory>`_ * `SetFilename <#SetFilename>`_ * `SetFilterIndex <#SetFilterIndex>`_ * `SetMessage <#SetMessage>`_ * `SetPath <#SetPath>`_ * `SetWildcard <#SetWildcard>`_ * `ShowModal <#ShowModal>`_ Properties Summary ^^^^^^^^^^^^^^^^^^ * `Directory <#Directory>`_ * `Filename <#Filename>`_ * `Filenames <#Filenames>`_ * `FilterIndex <#FilterIndex>`_ * `Message <#Message>`_ * `Path <#Path>`_ * `Paths <#Paths>`_ * `Wildcard <#Wildcard>`_ Class API ========= Methods ^^^^^^^ .. method:: __init__(parent, message=wx.FileSelectorPromptStr, defaultDir="", defaultFile="", wildcard=wx.FileSelectorDefaultWildcardStr, style=wx.FD_DEFAULT_STYLE, pos=wx.DefaultPosition) Constructor. Use `ShowModal <#ShowModal>`_ method to show the dialog. **Parameters:** * `parent` (`wx.Window `_) * `message` (string) * `defaultDir` (string) * `defaultFile` (string) * `wildcard` (string) * `style` (long) * `pos` (`wx.Point `_) | **Returns:** `wx.FileDialog `_ -------- .. method:: GetDirectory() Returns the default directory. | **Returns:** `string` -------- .. method:: GetFilename() Returns the default filename. | **Returns:** `string` -------- .. method:: GetFilenames() Returns a list of filenames chosen in the dialog. This function should only be used with the dialogs which have ``wx.FD_MULTIPLE`` style, use `GetFilename <#GetFilename>`_ for the others. | **Returns:** `list of strings` .. note:: 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. -------- .. method:: GetFilterIndex() 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. | **Returns:** `int` -------- .. method:: GetMessage() Returns the message that will be displayed on the dialog. | **Returns:** `string` -------- .. method:: GetPath() Returns the full path (directory and filename) of the selected file. | **Returns:** `string` -------- .. method:: GetPaths() Returns an array of paths with the full paths of the files chosen. This function should only be used with the dialogs which have ``wx.FD_MULTIPLE`` style, use `GetPath <#GetPath>`_ for the others. | **Returns:** `list of strings` -------- .. method:: GetWildcard() Returns the file dialog wildcard. | **Returns:** `string` -------- .. method:: SetDirectory(directory) Sets the default directory. **Parameters:** * `directory` (string) -------- .. method:: SetFilename(setfilename) Sets the default filename. **Parameters:** * `setfilename` (string) -------- .. method:: SetFilterIndex(filterIndex) Sets the default filter index, starting from zero. **Parameters:** * `filterIndex` (int) -------- .. method:: SetMessage(message) Sets the message that will be displayed on the dialog. **Parameters:** * `message` (string) -------- .. method:: SetPath(path) Sets the path (the combined directory and filename that will be returned when the dialog is dismissed). **Parameters:** * `path` (string) -------- .. method:: SetWildcard(wildCard) Sets the wildcard, which can contain multiple file types, for example:: "BMP files (*.bmp)|*.bmp | GIF files (*.gif)|*.gif" **Parameters:** * `wildCard` (string) .. note:: Note that the native Motif dialog has some limitations with respect to wildcards; see the note above. -------- .. method:: ShowModal() Shows the dialog, returning one of ``wx.ID_OK`` or ``wx.ID_CANCEL``. | **Returns:** `int` -------- Properties ^^^^^^^^^^ .. attribute:: Directory See `GetDirectory <#GetDirectory>`_ and `SetDirectory <#SetDirectory>`_ .. attribute:: Filename See `GetFilename <#GetFilename>`_ and `SetFilename <#SetFilename>`_ .. attribute:: Filenames See `GetFilenames <#GetFilenames>`_ .. attribute:: FilterIndex See `GetFilterIndex <#GetFilterIndex>`_ and `SetFilterIndex <#SetFilterIndex>`_ .. attribute:: Message See `GetMessage <#GetMessage>`_ and `SetMessage <#SetMessage>`_ .. attribute:: Path See `GetPath <#GetPath>`_ and `SetPath <#SetPath>`_ .. attribute:: Paths See `GetPaths <#GetPaths>`_ .. attribute:: Wildcard See `GetWildcard <#GetWildcard>`_ and `SetWildcard <#SetWildcard>`_