.. 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.svg" 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="This control can be used to place a directory listing (with optional files) on an arbitrary window." alt="" coords="44,313,199,341"/> <area shape="rect" id="node2" href="wx.Control.html" title="This is the base class for a control or 'widget'." alt="" coords="69,236,174,265"/> <area shape="rect" id="node3" href="wx.Window.html" title="wx.Window  is the base class for all windows and represents any visible object on screen." alt="" coords="66,159,177,188"/> <area shape="rect" id="node4" href="wx.EvtHandler.html" title="A class that can handle events from the windowing system." alt="" coords="55,82,188,111"/> <area shape="rect" id="node5" href="wx.Object.html" title="This is the root class of many of the wxWidgets classes." alt="" coords="5,5,104,34"/> <area shape="rect" id="node6" href="wx.Trackable.html" title="Add-on base class for a trackable object." alt="" coords="128,5,251,34"/> </map> 
   </p>
   </div>

|


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

|

.. container:: control-appearance-figures

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

      **wxMSW**


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

      **wxMAC**


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

      **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() -> None
       
       GenericDirCtrl(parent : Window, id: int=ID_ANY, dir:
                      str=DirDialogDefaultFolderStr, pos: Point=DefaultPosition, size:
                      Size=DefaultSize, style: int=DIRCTRL_DEFAULT_STYLE, filter: str='',
                      defaultFilter: int=0, name: str=TreeCtrlNameStr) -> None
       
   
   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. 
                       
      
      :rtype: `None`     
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **__init__** `(self, parent : Window, id: int=ID_ANY, dir: str=DirDialogDefaultFolderStr, pos: Point=DefaultPosition, size: Size=DefaultSize, style: int=DIRCTRL_DEFAULT_STYLE, filter: str='', defaultFilter: int=0, name: str=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
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      :rtype: `None`     
      
      
      
      
                        
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. method:: CollapsePath(self, path : str)

      Collapse the given `path`. 
                 


      :param `path`: 
      :type `path`: string




      :rtype: `bool`








   .. method:: CollapseTree(self)

      Collapses the entire tree. 
                 

      :rtype: `None`     








   .. method:: Create(self, parent : Window, id: int=ID_ANY, dir: str=DirDialogDefaultFolderStr, pos: Point=DefaultPosition, size: Size=DefaultSize, style: int=DIRCTRL_DEFAULT_STYLE, filter: str='', defaultFilter: int=0, name: str=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 : str)

      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: WindowVariant=WINDOW_VARIANT_NORMAL)




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




      :rtype: :ref:`wx.VisualAttributes`








   .. method:: GetDefaultPath(self)

      Gets the default path. 
                 

      :rtype: `str`








   .. method:: GetFilePath(self)

      Gets selected filename path only (else empty string). 
                 

      This function doesn't count a directory as a selection. 
                 

      :rtype: `str`








   .. method:: GetFilePaths(self, paths : List[str])

      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




      :rtype: `None`     








   .. method:: GetFilter(self)

      Returns the filter string. 
                 

      :rtype: `str`








   .. 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: `str`
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **GetPath** `(self, itemId : TreeItemId)`
      
      Gets the path corresponding to the given tree control item. 
                       
      
      
                      
      
      
      :param `itemId`: 
      :type `itemId`: wx.TreeItemId
      
      
      
      
      :rtype: `str`
      
      
      
      
      
      
      
      .. 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. 
                 

      :rtype: `None`     








   .. method:: ReCreateTree(self)

      Collapse and expand the tree, thus re-creating it from scratch. 
                 

      May be used to update the displayed directory content. 
                 

      :rtype: `None`     








   .. method:: SelectPath(self, path : str, select: bool=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




      :rtype: `None`     








   .. method:: SelectPaths(self, paths : List[str])

      Selects only the specified paths, clearing any previous selection. 
                 

      Only supported when ``wx.DIRCTRL_MULTIPLE`` is set. 
                 


      :param `paths`: 
      :type `paths`: list of strings




      :rtype: `None`     








   .. method:: SetDefaultPath(self, path : str)

      Sets the default path. 
                 


      :param `path`: 
      :type `path`: string




      :rtype: `None`     








   .. method:: SetFilter(self, filter : str)

      Sets the filter string. 
                 


      :param `filter`: 
      :type `filter`: string




      :rtype: `None`     








   .. method:: SetFilterIndex(self, n : int)

      Sets the current filter index (zero-based). 
                 


      :param `n`: 
      :type `n`: int




      :rtype: `None`     








   .. method:: SetPath(self, path : str)

      Sets the current path. 
                 


      :param `path`: 
      :type `path`: string




      :rtype: `None`     








   .. method:: ShowHidden(self, show : bool)






      :param `show`: If ``True``, hidden folders and files will be displayed by the control. If ``False``, they will not be displayed.   
      :type `show`: bool






      :rtype: `None`     




                  





   .. method:: UnselectAll(self)

      Removes the selection from all currently selected items. 
                 

      :rtype: `None`     








   .. 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`