.. wxPython Phoenix documentation

   This file was generated by Phoenix's sphinx generator and associated
   tools, do not edit by hand.

   Copyright: (c) 2011-2020 by Total Control Software
   License:   wxWindows License

.. include:: headings.inc



.. _wx.GenericDirCtrl:

==========================================================================================================================================
|phoenix_title|  **wx.GenericDirCtrl**
==========================================================================================================================================

This control can be used to place a directory listing (with optional files) on an arbitrary window.          

The control contains a :ref:`wx.TreeCtrl`  window representing the directory hierarchy, and optionally, a :ref:`wx.Choice`  window containing a list of filters. 

^^ 



.. _GenericDirCtrl-styles:

|styles| Window Styles
================================

This class supports the following styles: 

  

- ``wx.DIRCTRL_DIR_ONLY``: Only show directories, and not files.  
- ``wx.DIRCTRL_3D_INTERNAL``: Use 3D borders for internal controls. This is the default.  
- ``wx.DIRCTRL_SELECT_FIRST``: When setting the default path, select the first file in the directory.  
- ``wx.DIRCTRL_SHOW_FILTERS``: Show the drop-down filter list.  
- ``wx.DIRCTRL_EDIT_LABELS``: Allow the folder and file labels to be editable.  
- ``wx.DIRCTRL_MULTIPLE``: Allows multiple files and folders to be selected. ^^ 






^^ 



.. _GenericDirCtrl-events:

|events| Events Emitted by this Class
=====================================

Event macros for events emitted by this class: 

  

- EVT_DIRCTRL_SELECTIONCHANGED: Selected directory has changed. Processes a  ``wxEVT_DIRCTRL_SELECTIONCHANGED``   event type. Notice that this event is generated even for the changes done by the program itself and not only those done by the user. Available since wxWidgets 2.9.5.   
- EVT_DIRCTRL_FILEACTIVATED: The user activated a file by double-clicking or pressing Enter. Available since wxWidgets 2.9.5. ^^  


          




|

|class_hierarchy| Class Hierarchy
=================================

.. raw:: html

   <div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
   <img id="toggleBlock-trigger" src="_static/images/closed.png"/>
   Inheritance diagram for class <strong>GenericDirCtrl</strong>:
   </div>
   <div id="toggleBlock-summary" style="display:block;"></div>
   <div id="toggleBlock-content" style="display:none;">
   <p class="graphviz">
   <center><img src="_static/images/inheritance/wx.GenericDirCtrl_inheritance.png" alt="Inheritance diagram of GenericDirCtrl" usemap="#dummy" class="inheritance"/></center>
   <script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
   <map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.GenericDirCtrl.html" title="wx.GenericDirCtrl" alt="" coords="40,315,177,344"/> <area shape="rect" id="node2" href="wx.Control.html" title="wx.Control" alt="" coords="63,237,155,267"/> <area shape="rect" id="node3" href="wx.Window.html" title="wx.Window" alt="" coords="60,160,157,189"/> <area shape="rect" id="node4" href="wx.EvtHandler.html" title="wx.EvtHandler" alt="" coords="50,83,167,112"/> <area shape="rect" id="node5" href="wx.Object.html" title="wx.Object" alt="" coords="5,5,92,35"/> <area shape="rect" id="node6" href="wx.Trackable.html" title="wx.Trackable" alt="" coords="117,5,223,35"/> </map> 
   </p>
   </div>

|


|appearance| Control Appearance
===============================

|

.. figure:: _static/images/widgets/fullsize/wxmsw/wx.genericdirctrl.png
   :alt: wxMSW
   :figclass: floatleft

   **wxMSW**


.. figure:: _static/images/widgets/fullsize/wxmac/wx.genericdirctrl.png
   :alt: wxMAC
   :figclass: floatright

   **wxMAC**


.. figure:: _static/images/widgets/fullsize/wxgtk/wx.genericdirctrl.png
   :alt: wxGTK
   :figclass: floatcenter

   **wxGTK**


|


|method_summary| Methods Summary
================================

================================================================================ ================================================================================
:meth:`~wx.GenericDirCtrl.__init__`                                              Default constructor.
:meth:`~wx.GenericDirCtrl.CollapsePath`                                          Collapse the given `path`.
:meth:`~wx.GenericDirCtrl.CollapseTree`                                          Collapses the entire tree.
:meth:`~wx.GenericDirCtrl.Create`                                                Create function for two-step construction.
:meth:`~wx.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:`~wx.GenericDirCtrl.GetClassDefaultAttributes`                             
:meth:`~wx.GenericDirCtrl.GetDefaultPath`                                        Gets the default path.
:meth:`~wx.GenericDirCtrl.GetFilePath`                                           Gets selected filename path only (else empty string).
:meth:`~wx.GenericDirCtrl.GetFilePaths`                                          Fills the array `paths`  with the currently selected filepaths.
:meth:`~wx.GenericDirCtrl.GetFilter`                                             Returns the filter string.
:meth:`~wx.GenericDirCtrl.GetFilterIndex`                                        Returns the current filter index (zero-based).
:meth:`~wx.GenericDirCtrl.GetFilterListCtrl`                                     Returns a pointer to the filter list control (if present).
:meth:`~wx.GenericDirCtrl.GetPath`                                               Gets the currently-selected directory or filename.
:meth:`~wx.GenericDirCtrl.GetPaths`                                              Returns a list of the currently selected paths.
:meth:`~wx.GenericDirCtrl.GetRootId`                                             Returns the root id for the tree control.
:meth:`~wx.GenericDirCtrl.GetTreeCtrl`                                           Returns a pointer to the tree control.
:meth:`~wx.GenericDirCtrl.Init`                                                  Initializes variables.
:meth:`~wx.GenericDirCtrl.ReCreateTree`                                          Collapse and expand the tree, thus re-creating it from scratch.
:meth:`~wx.GenericDirCtrl.SelectPath`                                            Selects the given item.
:meth:`~wx.GenericDirCtrl.SelectPaths`                                           Selects only the specified paths, clearing any previous selection.
:meth:`~wx.GenericDirCtrl.SetDefaultPath`                                        Sets the default path.
:meth:`~wx.GenericDirCtrl.SetFilter`                                             Sets the filter string.
:meth:`~wx.GenericDirCtrl.SetFilterIndex`                                        Sets the current filter index (zero-based).
:meth:`~wx.GenericDirCtrl.SetPath`                                               Sets the current path.
:meth:`~wx.GenericDirCtrl.ShowHidden`                                            
:meth:`~wx.GenericDirCtrl.UnselectAll`                                           Removes the selection from all currently selected items.
================================================================================ ================================================================================


|


|property_summary| Properties Summary
=====================================

================================================================================ ================================================================================
:attr:`~wx.GenericDirCtrl.DefaultPath`                                           See :meth:`~wx.GenericDirCtrl.GetDefaultPath` and :meth:`~wx.GenericDirCtrl.SetDefaultPath`
:attr:`~wx.GenericDirCtrl.FilePath`                                              See :meth:`~wx.GenericDirCtrl.GetFilePath`
:attr:`~wx.GenericDirCtrl.Filter`                                                See :meth:`~wx.GenericDirCtrl.GetFilter` and :meth:`~wx.GenericDirCtrl.SetFilter`
:attr:`~wx.GenericDirCtrl.FilterIndex`                                           See :meth:`~wx.GenericDirCtrl.GetFilterIndex` and :meth:`~wx.GenericDirCtrl.SetFilterIndex`
:attr:`~wx.GenericDirCtrl.FilterListCtrl`                                        See :meth:`~wx.GenericDirCtrl.GetFilterListCtrl`
:attr:`~wx.GenericDirCtrl.Path`                                                  See :meth:`~wx.GenericDirCtrl.GetPath` and :meth:`~wx.GenericDirCtrl.SetPath`
:attr:`~wx.GenericDirCtrl.Paths`                                                 See :meth:`~wx.GenericDirCtrl.GetPaths`
:attr:`~wx.GenericDirCtrl.RootId`                                                See :meth:`~wx.GenericDirCtrl.GetRootId`
:attr:`~wx.GenericDirCtrl.TreeCtrl`                                              See :meth:`~wx.GenericDirCtrl.GetTreeCtrl`
================================================================================ ================================================================================


|


|api| Class API
===============


.. class:: wx.GenericDirCtrl(Control)

   **Possible constructors**::

       GenericDirCtrl()
       
       GenericDirCtrl(parent, id=ID_ANY, dir=DirDialogDefaultFolderStr,
                      pos=DefaultPosition, size=DefaultSize, style=DIRCTRL_DEFAULT_STYLE,
                      filter=EmptyString, defaultFilter=0, name=TreeCtrlNameStr)
       
   
   This control can be used to place a directory listing (with optional
   files) on an arbitrary window.



   .. method:: __init__(self, *args, **kw)



      |overload| Overloaded Implementations:

      :html:`<hr class="overloadsep" /><br />`

      
      **__init__** `(self)`
      
      Default constructor.                   
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **__init__** `(self, parent, id=ID_ANY, dir=DirDialogDefaultFolderStr, pos=DefaultPosition, size=DefaultSize, style=DIRCTRL_DEFAULT_STYLE, filter=EmptyString, defaultFilter=0, name=TreeCtrlNameStr)`
      
      Main constructor.                  
      
      
      
      
      :param `parent`: Parent window.   
      :type `parent`: wx.Window
      :param `id`: Window identifier.   
      :type `id`: wx.WindowID
      :param `dir`: Initial folder.   
      :type `dir`: string
      :param `pos`: Position.   
      :type `pos`: wx.Point
      :param `size`: Size.   
      :type `size`: wx.Size
      :param `style`: Window style. Please see :ref:`wx.GenericDirCtrl`  for a list of possible styles.   
      :type `style`: long
      :param `filter`: A filter string, using the same syntax as that for :ref:`wx.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
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
                        
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. 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_DEFAULT_STYLE, filter=EmptyString, defaultFilter=0, name=TreeCtrlNameStr)

      Create function for two-step construction.                  

      See :ref:`wx.GenericDirCtrl`  for details.                  


      :param `parent`: 
      :type `parent`: wx.Window
      :param `id`: 
      :type `id`: wx.WindowID
      :param `dir`: 
      :type `dir`: string
      :param `pos`: 
      :type `pos`: wx.Point
      :param `size`: 
      :type `size`: wx.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`








   .. staticmethod:: GetClassDefaultAttributes(variant=WINDOW_VARIANT_NORMAL)




      :param `variant`: 
      :type `variant`: wx.WindowVariant




      :rtype: :ref:`wx.VisualAttributes`








   .. 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:`wx.DirFilterListCtrl`








   .. method:: GetPath(self, *args, **kw)



      |overload| Overloaded Implementations:

      :html:`<hr class="overloadsep" /><br />`

      
      **GetPath** `(self)`
      
      Gets the currently-selected directory or filename.                  
      
      :rtype: `string`
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **GetPath** `(self, itemId)`
      
      Gets the path corresponding to the given tree control item.                  
      
                      
      
      
      :param `itemId`: 
      :type `itemId`: wx.TreeItemId
      
      
      
      
      :rtype: `string`
      
      
      
      
      
      
      
      .. versionadded:: 2.9.5 
           
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. method:: GetPaths(self)

      Returns a list of the currently selected paths. 

      :rtype: `list`








   .. method:: GetRootId(self)

      Returns the root id for the tree control.                  

      :rtype: :ref:`wx.TreeItemId`








   .. method:: GetTreeCtrl(self)

      Returns a pointer to the tree control.                  

      :rtype: :ref:`wx.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 ``wx.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:`~wx.GenericDirCtrl.GetDefaultPath` and :meth:`~wx.GenericDirCtrl.SetDefaultPath`


   .. attribute:: FilePath

      See :meth:`~wx.GenericDirCtrl.GetFilePath`


   .. attribute:: Filter

      See :meth:`~wx.GenericDirCtrl.GetFilter` and :meth:`~wx.GenericDirCtrl.SetFilter`


   .. attribute:: FilterIndex

      See :meth:`~wx.GenericDirCtrl.GetFilterIndex` and :meth:`~wx.GenericDirCtrl.SetFilterIndex`


   .. attribute:: FilterListCtrl

      See :meth:`~wx.GenericDirCtrl.GetFilterListCtrl`


   .. attribute:: Path

      See :meth:`~wx.GenericDirCtrl.GetPath` and :meth:`~wx.GenericDirCtrl.SetPath`


   .. attribute:: Paths

      See :meth:`~wx.GenericDirCtrl.GetPaths`


   .. attribute:: RootId

      See :meth:`~wx.GenericDirCtrl.GetRootId`


   .. attribute:: TreeCtrl

      See :meth:`~wx.GenericDirCtrl.GetTreeCtrl`

