.. wxPython Phoenix documentation

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

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

.. include:: headings.inc



.. _wx.FilePickerCtrl:

==========================================================================================================================================
|phoenix_title|  **wx.FilePickerCtrl**
==========================================================================================================================================

This control allows the user to select a file.          

The generic implementation is a button which brings up a :ref:`wx.FileDialog`  when clicked. Native implementation may differ but this is usually a (small) widget which give access to the file-chooser dialog. It is only available if  ``USE_FILEPICKERCTRL``   is set to 1 (the default). 





.. _FilePickerCtrl-styles:

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

This class supports the following styles: 

  

- ``wx.FLP_DEFAULT_STYLE``: The default style: includes ``wx.FLP_OPEN`` | ``wx.FLP_FILE_MUST_EXIST`` and, under wxMSW only, ``wx.FLP_USE_TEXTCTRL``.  
- ``wx.FLP_USE_TEXTCTRL``: Creates a text control to the left of the picker button which is completely managed by the :ref:`wx.FilePickerCtrl`  and which can be used by the user to specify a path (see SetPath). The text control is automatically synchronized with button's value. Use functions defined in :ref:`wx.PickerBase`  to modify the text control.  
- ``wx.FLP_OPEN``: Creates a picker which allows the user to select a file to open.  
- ``wx.FLP_SAVE``: Creates a picker which allows the user to select a file to save.  
- ``wx.FLP_OVERWRITE_PROMPT``: Can be combined with ``wx.FLP_SAVE`` only: ask confirmation to the user before selecting a file.  
- ``wx.FLP_FILE_MUST_EXIST``: Can be combined with ``wx.FLP_OPEN`` only: the selected file must be an existing file.  
- ``wx.FLP_CHANGE_DIR``: Change current working directory on each user file selection change.  
- ``wx.FLP_SMALL``: Use smaller version of the control with a small "..." button instead of the normal "Browse" one. This flag is new since wxWidgets 2.9.3.  








.. _FilePickerCtrl-events:

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

Handlers bound for the following event types will receive a :ref:`wx.FileDirPickerEvent` parameter.


- EVT_FILEPICKER_CHANGED: The user changed the file selected in the control either using the button or using text control (see ``wx.FLP_USE_TEXTCTRL``; note that in this case the event is fired only if the user's input is valid, e.g. an existing file path if ``wx.FLP_FILE_MUST_EXIST`` was given).  








         



.. seealso:: :ref:`wx.FileDialog`, :ref:`wx.FileDirPickerEvent`    







|

|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>FilePickerCtrl</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.FilePickerCtrl_inheritance.png" alt="Inheritance diagram of FilePickerCtrl" usemap="#dummy" class="inheritance"/></center>
   </div>
   <script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
   <map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.Control.html" title="wx.Control" alt="" coords="60,237,148,267"/> <area shape="rect" id="node7" href="wx.PickerBase.html" title="wx.PickerBase" alt="" coords="48,315,159,344"/> <area shape="rect" id="node2" href="wx.Window.html" title="wx.Window" alt="" coords="59,160,148,189"/> <area shape="rect" id="node3" href="wx.Object.html" title="wx.Object" alt="" coords="5,5,87,35"/> <area shape="rect" id="node4" href="wx.EvtHandler.html" title="wx.EvtHandler" alt="" coords="48,83,159,112"/> <area shape="rect" id="node5" href="wx.Trackable.html" title="wx.Trackable" alt="" coords="112,5,213,35"/> <area shape="rect" id="node6" href="wx.FilePickerCtrl.html" title="wx.FilePickerCtrl" alt="" coords="43,392,165,421"/> </map> 
   </p>

|


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

|

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

   **wxMSW**


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

   **wxMAC**


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

   **wxGTK**


|


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

================================================================================ ================================================================================
:meth:`~wx.FilePickerCtrl.__init__`                                              
:meth:`~wx.FilePickerCtrl.Create`                                                Creates this widget with the given parameters.
:meth:`~wx.FilePickerCtrl.GetClassDefaultAttributes`                             
:meth:`~wx.FilePickerCtrl.GetPath`                                               Returns the absolute path of the currently selected file.
:meth:`~wx.FilePickerCtrl.SetInitialDirectory`                                   Set the directory to show when starting to browse for files.
:meth:`~wx.FilePickerCtrl.SetPath`                                               Sets the absolute path of the currently selected file.
================================================================================ ================================================================================


|


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

================================================================================ ================================================================================
:attr:`~wx.FilePickerCtrl.Path`                                                  See :meth:`~wx.FilePickerCtrl.GetPath` and :meth:`~wx.FilePickerCtrl.SetPath`
================================================================================ ================================================================================


|


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


.. class:: wx.FilePickerCtrl(PickerBase)

   **Possible constructors**::

       FilePickerCtrl()
       
       FilePickerCtrl(parent, id=ID_ANY, path=EmptyString,
                      message=FileSelectorPromptStr, wildcard=FileSelectorDefaultWildcardStr,
                      pos=DefaultPosition, size=DefaultSize, style=FLP_DEFAULT_STYLE,
                      validator=DefaultValidator, name=FilePickerCtrlNameStr)
       
   
   This control allows the user to select a file.



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



      |overload| Overloaded Implementations:

      **~~~**

      
      **__init__** `(self)`
      
      
      
      
      
      **~~~**

      
      **__init__** `(self, parent, id=ID_ANY, path=EmptyString, message=FileSelectorPromptStr, wildcard=FileSelectorDefaultWildcardStr, pos=DefaultPosition, size=DefaultSize, style=FLP_DEFAULT_STYLE, validator=DefaultValidator, name=FilePickerCtrlNameStr)`
      
      Initializes the object and calls :meth:`Create`   with all the parameters.                  
      
      
      :param `parent`: 
      :type `parent`: wx.Window
      :param `id`: 
      :type `id`: wx.WindowID
      :param `path`: 
      :type `path`: string
      :param `message`: 
      :type `message`: string
      :param `wildcard`: 
      :type `wildcard`: string
      :param `pos`: 
      :type `pos`: wx.Point
      :param `size`: 
      :type `size`: wx.Size
      :param `style`: 
      :type `style`: long
      :param `validator`: 
      :type `validator`: wx.Validator
      :param `name`: 
      :type `name`: string
      
      
      
      
      
      
      **~~~**






   .. method:: Create(self, parent, id=ID_ANY, path=EmptyString, message=FileSelectorPromptStr, wildcard=FileSelectorDefaultWildcardStr, pos=DefaultPosition, size=DefaultSize, style=FLP_DEFAULT_STYLE, validator=DefaultValidator, name=FilePickerCtrlNameStr)

      Creates this widget with the given parameters.                  




      :param `parent`: Parent window, must not be non-NULL.   
      :type `parent`: wx.Window
      :param `id`: The identifier for the control.   
      :type `id`: wx.WindowID
      :param `path`: The initial file shown in the control. Must be a valid path to a file or the empty string.   
      :type `path`: string
      :param `message`: The message shown to the user in the :ref:`wx.FileDialog`  shown by the control.   
      :type `message`: string
      :param `wildcard`: A wildcard which defines user-selectable files (use the same syntax as for :ref:`wx.FileDialog`'s wildcards).   
      :type `wildcard`: string
      :param `pos`: Initial position.   
      :type `pos`: wx.Point
      :param `size`: Initial size.   
      :type `size`: wx.Size
      :param `style`: The window style, see ``FLP_`` flags.   
      :type `style`: long
      :param `validator`: Validator which can be used for additional data checks.   
      :type `validator`: wx.Validator
      :param `name`: Control name.  
      :type `name`: string
























      :rtype: `bool`



                  



      :returns: 

         ``True`` if the control was successfully created or ``False`` if creation failed.   








   .. staticmethod:: GetClassDefaultAttributes(variant=WINDOW_VARIANT_NORMAL)




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




      :rtype: :ref:`wx.VisualAttributes`








   .. method:: GetPath(self)

      Returns the absolute path of the currently selected file.                  

      :rtype: `string`








   .. method:: SetInitialDirectory(self, dir)

      Set the directory to show when starting to browse for files.                  

      This function is mostly useful for the file picker controls which have no selection initially to configure the directory that should be shown if the user starts browsing for files as otherwise the directory of initially selected file is used, which is usually the desired behaviour and so the directory specified by this function is ignored in this case. 

                


      :param `dir`: 
      :type `dir`: string






      .. versionadded:: 2.9.4 
     








   .. method:: SetPath(self, filename)

      Sets the absolute path of the currently selected file.                  

      This must be a valid file if the  ``FLP_FILE_MUST_EXIST``   style was given.                   


      :param `filename`: 
      :type `filename`: string







   .. attribute:: Path

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

