.. include:: headings.inc .. _GenericDirCtrl: ========================================================================================================================================== |phoenix_title| **GenericDirCtrl** ========================================================================================================================================== This control can be used to place a directory listing (with optional files) on an arbitrary window. The control contains a :ref:`TreeCtrl` window representing the directory hierarchy, and optionally, a :ref:`Choice` window containing a list of filters. .. _GenericDirCtrl-styles: |styles| Window Styles ================================ This class supports the following styles: - ``DIRCTRL_DIR_ONLY``: Only show directories, and not files. - ``DIRCTRL_3D_INTERNAL``: Use 3D borders for internal controls. - ``DIRCTRL_SELECT_FIRST``: When setting the default path, select the first file in the directory. - ``DIRCTRL_EDIT_LABELS``: Allow the folder and file labels to be editable. - ``DIRCTRL_MULTIPLE``: Allows multiple files and folders to be selected. | |class_hierarchy| Inheritance Diagram ===================================== Inheritance diagram for class **GenericDirCtrl** .. raw:: html

Inheritance diagram of GenericDirCtrl

| |appearance| Control Appearance =============================== | .. figure:: _static/images/widgets/fullsize/wxmsw/genericdirctrl.png :alt: wxMSW :figclass: floatleft **wxMSW** .. figure:: _static/images/widgets/fullsize/wxmac/genericdirctrl.png :alt: wxMAC :figclass: floatright **wxMAC** .. figure:: _static/images/widgets/fullsize/wxgtk/genericdirctrl.png :alt: wxGTK :figclass: floatcenter **wxGTK** | |method_summary| Methods Summary ================================ ================================================================================ ================================================================================ :meth:`~GenericDirCtrl.__init__` Default constructor. :meth:`~GenericDirCtrl.CollapsePath` Collapse the given `path`. :meth:`~GenericDirCtrl.CollapseTree` Collapses the entire tree. :meth:`~GenericDirCtrl.Create` Create function for two-step construction. :meth:`~GenericDirCtrl.ExpandPath` Tries to expand as much of the given `path` as possible, so that the filename or directory is visible in the tree control. :meth:`~GenericDirCtrl.GetDefaultPath` Gets the default path. :meth:`~GenericDirCtrl.GetFilePath` Gets selected filename path only (else empty string). :meth:`~GenericDirCtrl.GetFilePaths` Fills the array `paths` with the currently selected filepaths. :meth:`~GenericDirCtrl.GetFilter` Returns the filter string. :meth:`~GenericDirCtrl.GetFilterIndex` Returns the current filter index (zero-based). :meth:`~GenericDirCtrl.GetFilterListCtrl` Returns a pointer to the filter list control (if present). :meth:`~GenericDirCtrl.GetPath` Gets the currently-selected directory or filename. :meth:`~GenericDirCtrl.GetPaths` Fills the array `paths` with the selected directories and filenames. :meth:`~GenericDirCtrl.GetRootId` Returns the root id for the tree control. :meth:`~GenericDirCtrl.GetTreeCtrl` Returns a pointer to the tree control. :meth:`~GenericDirCtrl.Init` Initializes variables. :meth:`~GenericDirCtrl.ReCreateTree` Collapse and expand the tree, thus re-creating it from scratch. :meth:`~GenericDirCtrl.SelectPath` Selects the given item. :meth:`~GenericDirCtrl.SelectPaths` Selects only the specified paths, clearing any previous selection. :meth:`~GenericDirCtrl.SetDefaultPath` Sets the default path. :meth:`~GenericDirCtrl.SetFilter` Sets the filter string. :meth:`~GenericDirCtrl.SetFilterIndex` Sets the current filter index (zero-based). :meth:`~GenericDirCtrl.SetPath` Sets the current path. :meth:`~GenericDirCtrl.ShowHidden` :meth:`~GenericDirCtrl.UnselectAll` Removes the selection from all currently selected items. ================================================================================ ================================================================================ | |property_summary| Properties Summary ===================================== ================================================================================ ================================================================================ :attr:`~GenericDirCtrl.DefaultPath` See :meth:`~GenericDirCtrl.GetDefaultPath` and :meth:`~GenericDirCtrl.SetDefaultPath` :attr:`~GenericDirCtrl.FilePath` See :meth:`~GenericDirCtrl.GetFilePath` :attr:`~GenericDirCtrl.Filter` See :meth:`~GenericDirCtrl.GetFilter` and :meth:`~GenericDirCtrl.SetFilter` :attr:`~GenericDirCtrl.FilterIndex` See :meth:`~GenericDirCtrl.GetFilterIndex` and :meth:`~GenericDirCtrl.SetFilterIndex` :attr:`~GenericDirCtrl.FilterListCtrl` See :meth:`~GenericDirCtrl.GetFilterListCtrl` :attr:`~GenericDirCtrl.Path` See :meth:`~GenericDirCtrl.GetPath` and :meth:`~GenericDirCtrl.SetPath` :attr:`~GenericDirCtrl.RootId` See :meth:`~GenericDirCtrl.GetRootId` :attr:`~GenericDirCtrl.TreeCtrl` See :meth:`~GenericDirCtrl.GetTreeCtrl` ================================================================================ ================================================================================ | |api| Class API =============== .. class:: GenericDirCtrl(Control) This control can be used to place a directory listing (with optional files) on an arbitrary window. **Possible constructors**:: GenericDirCtrl() GenericDirCtrl(parent, id=ID_ANY, dir=DirDialogDefaultFolderStr, pos=DefaultPosition, size=DefaultSize, style=DIRCTRL_3D_INTERNAL, filter='', defaultFilter=0, name=TreeCtrlNameStr) .. method:: __init__(self, *args, **kw) |overload| **Overloaded Implementations**: **~~~** **__init__** `(self)` Default constructor. **~~~** **__init__** `(self, parent, id=ID_ANY, dir=DirDialogDefaultFolderStr, pos=DefaultPosition, size=DefaultSize, style=DIRCTRL_3D_INTERNAL, filter='', defaultFilter=0, name=TreeCtrlNameStr)` Main constructor. :param `parent`: Parent window. :type `parent`: Window :param `id`: Window identifier. :type `id`: int :param `dir`: Initial folder. :type `dir`: string :param `pos`: Position. :type `pos`: Point :param `size`: Size. :type `size`: Size :param `style`: Window style. Please see :ref:`GenericDirCtrl` for a list of possible styles. :type `style`: long :param `filter`: A filter string, using the same syntax as that for :ref:`FileDialog`. This may be empty if filters are not being used. Example: ``"All files (*.*)|*.*|JPEG files (*.jpg)|*.jpg"`` :type `filter`: string :param `defaultFilter`: The zero-indexed default filter setting. :type `defaultFilter`: int :param `name`: The window name. :type `name`: string **~~~** .. method:: CollapsePath(self, path) Collapse the given `path`. :param `path`: :type `path`: string :rtype: `bool` .. method:: CollapseTree(self) Collapses the entire tree. .. method:: Create(self, parent, id=ID_ANY, dir=DirDialogDefaultFolderStr, pos=DefaultPosition, size=DefaultSize, style=DIRCTRL_3D_INTERNAL, filter='', defaultFilter=0, name=TreeCtrlNameStr) Create function for two-step construction. See :ref:`GenericDirCtrl` for details. :param `parent`: :type `parent`: Window :param `id`: :type `id`: int :param `dir`: :type `dir`: string :param `pos`: :type `pos`: Point :param `size`: :type `size`: Size :param `style`: :type `style`: long :param `filter`: :type `filter`: string :param `defaultFilter`: :type `defaultFilter`: int :param `name`: :type `name`: string :rtype: `bool` .. method:: ExpandPath(self, path) Tries to expand as much of the given `path` as possible, so that the filename or directory is visible in the tree control. :param `path`: :type `path`: string :rtype: `bool` .. method:: GetDefaultPath(self) Gets the default path. :rtype: `string` .. method:: GetFilePath(self) Gets selected filename path only (else empty string). This function doesn't count a directory as a selection. :rtype: `string` .. method:: GetFilePaths(self, paths) Fills the array `paths` with the currently selected filepaths. This function doesn't count a directory as a selection. :param `paths`: :type `paths`: list of strings .. method:: GetFilter(self) Returns the filter string. :rtype: `string` .. method:: GetFilterIndex(self) Returns the current filter index (zero-based). :rtype: `int` .. method:: GetFilterListCtrl(self) Returns a pointer to the filter list control (if present). :rtype: :ref:`DirFilterListCtrl` .. method:: GetPath(self) Gets the currently-selected directory or filename. :rtype: `string` .. method:: GetPaths(self, paths) Fills the array `paths` with the selected directories and filenames. :param `paths`: :type `paths`: list of strings .. method:: GetRootId(self) Returns the root id for the tree control. :rtype: :ref:`TreeItemId` .. method:: GetTreeCtrl(self) Returns a pointer to the tree control. :rtype: :ref:`TreeCtrl` .. method:: Init(self) Initializes variables. .. method:: ReCreateTree(self) Collapse and expand the tree, thus re-creating it from scratch. May be used to update the displayed directory content. .. method:: SelectPath(self, path, select=True) Selects the given item. In multiple selection controls, can be also used to deselect a currently selected item if the value of `select` is ``False``. Existing selections are not changed. Only visible items can be (de)selected, otherwise use :meth:`ExpandPath` . :param `path`: :type `path`: string :param `select`: :type `select`: bool .. method:: SelectPaths(self, paths) Selects only the specified paths, clearing any previous selection. Only supported when ``DIRCTRL_MULTIPLE`` is set. :param `paths`: :type `paths`: list of strings .. method:: SetDefaultPath(self, path) Sets the default path. :param `path`: :type `path`: string .. method:: SetFilter(self, filter) Sets the filter string. :param `filter`: :type `filter`: string .. method:: SetFilterIndex(self, n) Sets the current filter index (zero-based). :param `n`: :type `n`: int .. method:: SetPath(self, path) Sets the current path. :param `path`: :type `path`: string .. method:: ShowHidden(self, show) :param `show`: If ``True``, hidden folders and files will be displayed by the control. If ``False``, they will not be displayed. :type `show`: bool .. method:: UnselectAll(self) Removes the selection from all currently selected items. .. attribute:: DefaultPath See :meth:`~GenericDirCtrl.GetDefaultPath` and :meth:`~GenericDirCtrl.SetDefaultPath` .. attribute:: FilePath See :meth:`~GenericDirCtrl.GetFilePath` .. attribute:: Filter See :meth:`~GenericDirCtrl.GetFilter` and :meth:`~GenericDirCtrl.SetFilter` .. attribute:: FilterIndex See :meth:`~GenericDirCtrl.GetFilterIndex` and :meth:`~GenericDirCtrl.SetFilterIndex` .. attribute:: FilterListCtrl See :meth:`~GenericDirCtrl.GetFilterListCtrl` .. attribute:: Path See :meth:`~GenericDirCtrl.GetPath` and :meth:`~GenericDirCtrl.SetPath` .. attribute:: RootId See :meth:`~GenericDirCtrl.GetRootId` .. attribute:: TreeCtrl See :meth:`~GenericDirCtrl.GetTreeCtrl`