.. include:: headings.inc .. _FileCtrl: ========================================================================================================================================== |phoenix_title| **FileCtrl** ========================================================================================================================================== This control allows the user to select a file. Two implementations of this class exist, one for Gtk and another generic one for all the other ports. This class is only available if ``USE_FILECTRL`` is set to 1. .. _FileCtrl-styles: |styles| Window Styles ================================ This class supports the following styles: - ``FC_DEFAULT_STYLE``: The default style: ``FC_OPEN`` - ``FC_OPEN``: Creates an file control suitable for opening files. Cannot be combined with ``FC_SAVE``. - ``FC_SAVE``: Creates an file control suitable for saving files. Cannot be combined with ``FC_OPEN``. - ``FC_MULTIPLE``: For open control only, Allows selecting multiple files. Cannot be combined with ``FC_SAVE`` - ``FC_NOSHOWHIDDEN``: Hides the "Show Hidden Files" checkbox (Generic only) .. _FileCtrl-events: |events| Events Emitted by this Class ===================================== Handlers bound for the following event types will receive a :ref:`FileCtrlEvent` parameter. - EVT_FILECTRL_FILEACTIVATED: The user activated a file(by double-clicking or pressing Enter) - EVT_FILECTRL_SELECTIONCHANGED: The user changed the current selection(by selecting or deselecting a file) - EVT_FILECTRL_FOLDERCHANGED: The current folder of the file control has been changed - EVT_FILECTRL_FILTERCHANGED: The current file filter of the file control has been changed. .. versionadded:: 2.9.1. Implementations:GTK port; a generic implementation is used elsewhere. .. seealso:: :ref:`GenericDirCtrl` | |class_hierarchy| Inheritance Diagram ===================================== Inheritance diagram for class **FileCtrl** .. raw:: html

Inheritance diagram of FileCtrl

| |appearance| Control Appearance =============================== | .. figure:: _static/images/widgets/fullsize/wxmsw/../no_appearance.png :alt: wxMSW :figclass: floatleft **wxMSW** .. figure:: _static/images/widgets/fullsize/wxmac/../no_appearance.png :alt: wxMAC :figclass: floatright **wxMAC** .. figure:: _static/images/widgets/fullsize/wxgtk/filectrl.png :alt: wxGTK :figclass: floatcenter **wxGTK** | |method_summary| Methods Summary ================================ ================================================================================ ================================================================================ :meth:`~FileCtrl.__init__` :meth:`~FileCtrl.Create` Create function for two-step construction. :meth:`~FileCtrl.GetDirectory` Returns the current directory of the file control (i.e. :meth:`~FileCtrl.GetFilename` Returns the currently selected filename. :meth:`~FileCtrl.GetFilterIndex` Returns the zero-based index of the currently selected filter. :meth:`~FileCtrl.GetPath` Returns the full path (directory and filename) of the currently selected file. :meth:`~FileCtrl.GetWildcard` Returns the current wildcard. :meth:`~FileCtrl.SetDirectory` Sets(changes) the current directory displayed in the control. :meth:`~FileCtrl.SetFilename` Selects a certain file. :meth:`~FileCtrl.SetFilterIndex` Sets the current filter index, starting from zero. :meth:`~FileCtrl.SetPath` Changes to a certain directory and selects a certain file. :meth:`~FileCtrl.SetWildcard` Sets the wildcard, which can contain multiple file types, for example: "``BMP`` files (.bmp)|.bmp|GIF files (.gif)|.gif". :meth:`~FileCtrl.ShowHidden` Sets whether hidden files and folders are shown or not. ================================================================================ ================================================================================ | |property_summary| Properties Summary ===================================== ================================================================================ ================================================================================ :attr:`~FileCtrl.Directory` See :meth:`~FileCtrl.GetDirectory` and :meth:`~FileCtrl.SetDirectory` :attr:`~FileCtrl.Filename` See :meth:`~FileCtrl.GetFilename` and :meth:`~FileCtrl.SetFilename` :attr:`~FileCtrl.Filenames` See :meth:`~FileCtrl.GetFilenames` :attr:`~FileCtrl.FilterIndex` See :meth:`~FileCtrl.GetFilterIndex` and :meth:`~FileCtrl.SetFilterIndex` :attr:`~FileCtrl.Path` See :meth:`~FileCtrl.GetPath` and :meth:`~FileCtrl.SetPath` :attr:`~FileCtrl.Paths` See :meth:`~FileCtrl.GetPaths` :attr:`~FileCtrl.Wildcard` See :meth:`~FileCtrl.GetWildcard` and :meth:`~FileCtrl.SetWildcard` ================================================================================ ================================================================================ | |api| Class API =============== .. class:: FileCtrl(Control) This control allows the user to select a file. **Possible constructors**:: FileCtrl() FileCtrl(parent, id=ID_ANY, defaultDirectory='', defaultFilename='', wildCard=FileSelectorDefaultWildcardStr, style=FC_DEFAULT_STYLE, pos=DefaultPosition, size=DefaultSize, name=FileCtrlNameStr) .. method:: __init__(self, *args, **kw) |overload| **Overloaded Implementations**: **~~~** **__init__** `(self)` **~~~** **__init__** `(self, parent, id=ID_ANY, defaultDirectory='', defaultFilename='', wildCard=FileSelectorDefaultWildcardStr, style=FC_DEFAULT_STYLE, pos=DefaultPosition, size=DefaultSize, name=FileCtrlNameStr)` Constructs the window. :param `parent`: Parent window, must not be not ``None``. :type `parent`: Window :param `id`: The identifier for the control. :type `id`: int :param `defaultDirectory`: The initial directory shown in the control. Must be a valid path to a directory or the empty string. In case it is the empty string, the current working directory is used. :type `defaultDirectory`: string :param `defaultFilename`: The default filename, or the empty string. :type `defaultFilename`: string :param `wildCard`: A wildcard specifying which files can be selected, such as "." or "``BMP`` files (.bmp)|.bmp|GIF files (.gif)|.gif". :type `wildCard`: string :param `style`: The window style, see ``FC_`` flags. :type `style`: long :param `pos`: Initial position. :type `pos`: Point :param `size`: Initial size. :type `size`: Size :param `name`: Control name. :type `name`: string :returns: ``True`` if the control was successfully created or ``False`` if creation failed. **~~~** .. method:: Create(self, parent, id=ID_ANY, defaultDirectory='', defaultFilename='', wildCard=FileSelectorDefaultWildcardStr, style=FC_DEFAULT_STYLE, pos=DefaultPosition, size=DefaultSize, name=FileCtrlNameStr) Create function for two-step construction. See :ref:`FileCtrl` for details. :param `parent`: :type `parent`: Window :param `id`: :type `id`: int :param `defaultDirectory`: :type `defaultDirectory`: string :param `defaultFilename`: :type `defaultFilename`: string :param `wildCard`: :type `wildCard`: string :param `style`: :type `style`: long :param `pos`: :type `pos`: Point :param `size`: :type `size`: Size :param `name`: :type `name`: string :rtype: `bool` .. method:: GetDirectory(self) Returns the current directory of the file control (i.e. the directory shown by it). :rtype: `string` .. method:: GetFilename(self) Returns the currently selected filename. For the controls having the ``FC_MULTIPLE`` style, use :meth:`GetFilenames` instead. :rtype: `string` .. method:: GetFilterIndex(self) Returns the zero-based index of the currently selected filter. :rtype: `int` .. method:: GetPath(self) Returns the full path (directory and filename) of the currently selected file. For the controls having the ``FC_MULTIPLE`` style, use :meth:`GetPaths` instead. :rtype: `string` .. method:: GetWildcard(self) Returns the current wildcard. :rtype: `string` .. method:: SetDirectory(self, directory) Sets(changes) the current directory displayed in the control. :param `directory`: :type `directory`: string :rtype: `bool` :returns: Returns ``True`` on success, ``False`` otherwise. .. method:: SetFilename(self, filename) Selects a certain file. :param `filename`: :type `filename`: string :rtype: `bool` :returns: Returns ``True`` on success, ``False`` otherwise .. method:: SetFilterIndex(self, filterIndex) Sets the current filter index, starting from zero. :param `filterIndex`: :type `filterIndex`: int .. method:: SetPath(self, path) Changes to a certain directory and selects a certain file. In case the filename specified isn't found/couldn't be shown with currently selected filter, ``False`` is returned. :param `path`: :type `path`: string :rtype: `bool` :returns: Returns ``True`` on success, ``False`` otherwise .. method:: SetWildcard(self, wildCard) Sets the wildcard, which can contain multiple file types, for example: "``BMP`` files (.bmp)|.bmp|GIF files (.gif)|.gif". :param `wildCard`: :type `wildCard`: string .. method:: ShowHidden(self, show) Sets whether hidden files and folders are shown or not. :param `show`: :type `show`: bool .. attribute:: Directory See :meth:`~FileCtrl.GetDirectory` and :meth:`~FileCtrl.SetDirectory` .. attribute:: Filename See :meth:`~FileCtrl.GetFilename` and :meth:`~FileCtrl.SetFilename` .. attribute:: Filenames See :meth:`~FileCtrl.GetFilenames` .. attribute:: FilterIndex See :meth:`~FileCtrl.GetFilterIndex` and :meth:`~FileCtrl.SetFilterIndex` .. attribute:: Path See :meth:`~FileCtrl.GetPath` and :meth:`~FileCtrl.SetPath` .. attribute:: Paths See :meth:`~FileCtrl.GetPaths` .. attribute:: Wildcard See :meth:`~FileCtrl.GetWildcard` and :meth:`~FileCtrl.SetWildcard`