.. 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.StandardPaths:

==========================================================================================================================================
|phoenix_title|  **wx.StandardPaths**
==========================================================================================================================================

:ref:`wx.StandardPaths`  returns the standard locations in the file system and should be used by applications to find their data files in a portable way.          

Note that you must not create objects of class :ref:`wx.StandardPaths`  directly, but use the global standard paths object returned by :meth:`wx.StandardPaths.Get`   (which can be of a type derived from :ref:`wx.StandardPaths`  and not of exactly this type) and call the methods you need on it. The object returned by :meth:`~wx.StandardPaths.Get`  may be customized by overriding :meth:`wx.AppTraits.GetStandardPaths`   methods. 

In the description of the methods below, the example return values are given for the Unix, Windows and macOS systems, however please note that these are just the examples and the actual values may differ. For example, under Windows: the system administrator may change the standard directories locations, e.g. the Windows directory may be named  ``"W:\Win2003"``   instead of the default   ``"C:\Windows"`` . 

Notice that in the examples below the string  ``appinfo``   may be either just the application name (as returned by  :meth:`wx.App.GetAppName` ) or a combination of the vendor name (:meth:`wx.App.GetVendorName` ) and the application name, with a path separator between them. By default, only the application name is used, use :meth:`~wx.StandardPaths.UseAppInfo`  to change this. 

The other placeholders should be self-explanatory: the string  ``username``   should be replaced with the value the name of the currently logged in user. and   ``prefix``   is only used under Unix and is   ``/usr/local``   by default but may be changed using  :meth:`wx.StandardPaths.SetInstallPrefix` . 

The directories returned by the methods of this class may or may not exist. If they don't exist, it's up to the caller to create them, :ref:`wx.StandardPaths`  doesn't do it. 

Finally note that these functions only work with standardly packaged applications. I.e. under Unix you should follow the standard installation conventions and under Mac you should create your application bundle according to the Apple guidelines. Again, this class doesn't help you to do it. 

This class is MT-safe: its methods may be called concurrently from different threads without additional locking. 







         



.. seealso:: :ref:`wx.FileConfig`    







|

|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>StandardPaths</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.StandardPaths_inheritance.png" alt="Inheritance diagram of StandardPaths" 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.StandardPaths.html" title="wx.StandardPaths" alt="" coords="5,5,144,35"/> </map> 
   </p>
   </div>

|


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

================================================================================ ================================================================================
:meth:`~wx.StandardPaths.Get`                                                    Returns reference to the unique global standard paths object.
:meth:`~wx.StandardPaths.GetAppDocumentsDir`                                     Return the directory for the document files used by this application.
:meth:`~wx.StandardPaths.GetConfigDir`                                           Return the directory containing the system config files.
:meth:`~wx.StandardPaths.GetDataDir`                                             Return the location of the applications global, i.e. not user-specific, data files.
:meth:`~wx.StandardPaths.GetDocumentsDir`                                        Same as calling :meth:`~StandardPaths.GetUserDir`   with Dir_Documents parameter.
:meth:`~wx.StandardPaths.GetExecutablePath`                                      Return the directory and the filename for the current executable.
:meth:`~wx.StandardPaths.GetFileLayout`                                          Returns the current file layout.
:meth:`~wx.StandardPaths.GetInstallPrefix`                                       Return the program installation prefix, e.g.  ``/usr`` ,   ``/opt``   or   ``/home/zeitlin`` .
:meth:`~wx.StandardPaths.GetLocalDataDir`                                        Return the location for application data files which are host-specific and can't, or shouldn't, be shared with the other machines.
:meth:`~wx.StandardPaths.GetLocalizedResourcesDir`                               Return the localized resources directory containing the resource files of the specified category for the given language.
:meth:`~wx.StandardPaths.GetPluginsDir`                                          Return the directory where the loadable modules (plugins) live.
:meth:`~wx.StandardPaths.GetResourcesDir`                                        Return the directory where the application resource files are located.
:meth:`~wx.StandardPaths.GetTempDir`                                             Return the directory for storing temporary files, for the current user.
:meth:`~wx.StandardPaths.GetUserConfigDir`                                       Return the directory for the user config files.
:meth:`~wx.StandardPaths.GetUserDataDir`                                         Return the directory for the user-dependent application data files
:meth:`~wx.StandardPaths.GetUserDir`                                             Return the path of the specified user data directory.
:meth:`~wx.StandardPaths.GetUserLocalDataDir`                                    Return the directory for user data files which shouldn't be shared with the other machines.
:meth:`~wx.StandardPaths.MSWGetShellDir`                                         Returns location of Windows shell special folder.
:meth:`~wx.StandardPaths.MakeConfigFileName`                                     Return the file name which would be used by :ref:`wx.FileConfig`  if it were constructed with `basename`.
:meth:`~wx.StandardPaths.SetFileLayout`                                          Sets the current file layout.
:meth:`~wx.StandardPaths.SetInstallPrefix`                                       Lets :ref:`wx.StandardPaths`  know about the real program installation prefix on a Unix system.
:meth:`~wx.StandardPaths.UseAppInfo`                                             Controls what application information is used when constructing paths that should be unique to this program, such as the application data directory, the plugins directory on Unix, etc.
:meth:`~wx.StandardPaths.__init__`                                               Protected default constructor.
================================================================================ ================================================================================


|


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

================================================================================ ================================================================================
:attr:`~wx.StandardPaths.AppDocumentsDir`                                        See :meth:`~wx.StandardPaths.GetAppDocumentsDir`
:attr:`~wx.StandardPaths.ConfigDir`                                              See :meth:`~wx.StandardPaths.GetConfigDir`
:attr:`~wx.StandardPaths.DataDir`                                                See :meth:`~wx.StandardPaths.GetDataDir`
:attr:`~wx.StandardPaths.DocumentsDir`                                           See :meth:`~wx.StandardPaths.GetDocumentsDir`
:attr:`~wx.StandardPaths.ExecutablePath`                                         See :meth:`~wx.StandardPaths.GetExecutablePath`
:attr:`~wx.StandardPaths.InstallPrefix`                                          See :meth:`~wx.StandardPaths.GetInstallPrefix` and :meth:`~wx.StandardPaths.SetInstallPrefix`
:attr:`~wx.StandardPaths.LocalDataDir`                                           See :meth:`~wx.StandardPaths.GetLocalDataDir`
:attr:`~wx.StandardPaths.PluginsDir`                                             See :meth:`~wx.StandardPaths.GetPluginsDir`
:attr:`~wx.StandardPaths.ResourcesDir`                                           See :meth:`~wx.StandardPaths.GetResourcesDir`
:attr:`~wx.StandardPaths.TempDir`                                                See :meth:`~wx.StandardPaths.GetTempDir`
:attr:`~wx.StandardPaths.UserConfigDir`                                          See :meth:`~wx.StandardPaths.GetUserConfigDir`
:attr:`~wx.StandardPaths.UserDataDir`                                            See :meth:`~wx.StandardPaths.GetUserDataDir`
:attr:`~wx.StandardPaths.UserLocalDataDir`                                       See :meth:`~wx.StandardPaths.GetUserLocalDataDir`
================================================================================ ================================================================================


|


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


.. class:: wx.StandardPaths(object)

   **Possible constructors**::

       StandardPaths()
       
   
   StandardPaths returns the standard locations in the file system and
   should be used by applications to find their data files in a portable
   way.



   .. staticmethod:: Get()

      Returns reference to the unique global standard paths object.                  

      :rtype: :ref:`wx.StandardPaths`








   .. method:: GetAppDocumentsDir(self)

      Return the directory for the document files used by this application.                  

      If the application-specific directory doesn't exist, this function returns :meth:`GetDocumentsDir` . 

      Example return values:

      - Unix:  ``~/appinfo``       
      - Windows:  ``"C:\Users\username\Documents\appinfo"``   or   ``"C:\Documents and Settings\username\My Documents\appinfo"``       
      - Mac:  ``~/Documents/appinfo``       




                

      :rtype: `string`







      .. versionadded:: 2.9.0 
     








   .. method:: GetConfigDir(self)

      Return the directory containing the system config files.                  

      Example return values:

      - Unix:  ``/etc``       
      - Windows:  ``"C:\ProgramData\appinfo"``   or   ``"C:\Documents and Settings\All Users\Application Data\appinfo"``       
      - Mac:  ``/Library/Preferences``       




                

      :rtype: `string`







      .. note:: 

         Under Windows this includes  ``appinfo``   which makes it inconsistent with other ports.  







      .. seealso:: :ref:`wx.FileConfig`    








   .. method:: GetDataDir(self)

      Return the location of the applications global, i.e. not user-specific, data files.                  

      Example return values:

      - Unix:  ``prefix/share/appinfo``       
      - Windows: the directory where the executable file is located 
      - Mac:  ``appinfo.app/Contents/SharedSupport``   bundle subdirectory 




      Under Unix (only) it is possible to override the default value returned from this function by setting the value of  ``WX_APPNAME_DATA_DIR``   environment variable to the directory to use (where   ``APPNAME``   is the upper-cased value of  :meth:`wx.App.GetAppName` ). This is useful in order to be able to run applications using this function without installing them as you can simply set this environment variable to the source directory location to allow the application to find its files there. 

                

      :rtype: `string`







      .. seealso:: :meth:`GetLocalDataDir`     








   .. method:: GetDocumentsDir(self)

      Same as calling :meth:`GetUserDir`   with Dir_Documents parameter.                  

                

      :rtype: `string`







      .. versionadded:: 2.7.0 
    







      .. seealso:: :meth:`GetAppDocumentsDir` , :meth:`GetUserDir`     








   .. method:: GetExecutablePath(self)

      Return the directory and the filename for the current executable.                  

      Example return values:

      - Unix:  ``/usr/local/bin/exename``       
      - Windows:  ``"C:\Programs\AppFolder\exename.exe"``       
      - Mac:  ``/Applications/exename`` .app/Contents/MacOS/exename   


                 

      :rtype: `string`








   .. method:: GetFileLayout(self)

      Returns the current file layout.                  

                

      :rtype: :ref:`wx.StandardPaths.FileLayout`







      .. versionadded:: 4.1/wxWidgets-3.1.1  
     







      .. seealso:: :meth:`SetFileLayout`   








   .. method:: GetInstallPrefix(self)

      Return the program installation prefix, e.g.  ``/usr`` ,   ``/opt``   or   ``/home/zeitlin`` .                   

      If the prefix had been previously by :meth:`SetInstallPrefix` , returns that value, otherwise tries to determine it automatically (Linux only right now) and finally returns the default  ``/usr/local``   value if it failed. 




      :rtype: `string`







      .. availability:: Only available for GTK.  







      .. note:: 

         This function is only available under Unix platforms (but not limited to wxGTK mentioned below).  








   .. method:: GetLocalDataDir(self)

      Return the location for application data files which are host-specific and can't, or shouldn't, be shared with the other machines.                  

      This is the same as :meth:`GetDataDir`   except under Unix where it returns  ``/etc/appinfo`` .                   

      :rtype: `string`








   .. method:: GetLocalizedResourcesDir(self, lang, category=ResourceCat_None)

      Return the localized resources directory containing the resource files of the specified category for the given language.                  

      In general this is just the same as `lang`  subdirectory of :meth:`GetResourcesDir`   (or  ``lang.lproj``   under macOS) but is something quite different for message catalog category under Unix where it returns the standard   ``prefix/share/locale/lang/LC_MESSAGES``   directory. 

                


      :param `lang`: 
      :type `lang`: string
      :param `category`: 
      :type `category`: wx.StandardPaths.ResourceCat




      :rtype: `string`







      .. versionadded:: 2.7.0 
     








   .. method:: GetPluginsDir(self)

      Return the directory where the loadable modules (plugins) live.                  

      Example return values:

      - Unix:  ``prefix/lib/appinfo``       
      - Windows: the directory of the executable file 
      - Mac:  ``appinfo.app/Contents/PlugIns``   bundle subdirectory 




                

      :rtype: `string`







      .. seealso:: :ref:`DynamicLibrary`    








   .. method:: GetResourcesDir(self)

      Return the directory where the application resource files are located.                  

      The resources are the auxiliary data files needed for the application to run and include, for example, image and sound files it might use. 

      This function is the same as :meth:`GetDataDir`   for all platforms except macOS. Example return values:

      - Unix:  ``prefix/share/appinfo``       
      - Windows: the directory where the executable file is located 
      - Mac:  ``appinfo.app/Contents/Resources``   bundle subdirectory 




                

      :rtype: `string`







      .. versionadded:: 2.7.0 
    







      .. seealso:: :meth:`GetLocalizedResourcesDir`     








   .. method:: GetTempDir(self)

      Return the directory for storing temporary files, for the current user.                  

      Same as :meth:`FileName.GetTempDir` . To create unique temporary files, it is best to use :meth:`FileName.CreateTempFileName`   for correct behaviour when multiple processes are attempting to create temporary files. 

                

      :rtype: `string`







      .. versionadded:: 2.7.2 
     








   .. method:: GetUserConfigDir(self)

      Return the directory for the user config files.                  

      This directory is:

      - Unix:  ``~``   (the home directory) or   ``XDG_CONFIG_HOME``   depending on  :meth:`GetFileLayout`   return value 
      - Windows:  ``"C:\Users\username\AppData\Roaming"``   or   ``"C:\Documents and Settings\username\Application Data"``       
      - Mac:  ``~/Library/Preferences``       




      Only use this method if you have a single configuration file to put in this directory, otherwise :meth:`GetUserDataDir`   is more appropriate as the latter adds  ``appinfo``   to the path, unlike this function.                   

      :rtype: `string`








   .. method:: GetUserDataDir(self)

      Return the directory for the user-dependent application data files:                  



      - Unix:  ``~/`` .appinfo 
      - Windows:  ``"C:\Users\username\AppData\Roaming\appinfo"``   or   ``"C:\Documents and Settings\username\Application Data\appinfo"``       
      - Mac:  ``"~/Library/Application Support/appinfo"``       


                 

      :rtype: `string`








   .. method:: GetUserDir(self, userDir)

      Return the path of the specified user data directory.                  

      If the value could not be determined the users home directory is returned. 

                


      :param `userDir`: 
      :type `userDir`: wx.StandardPaths.Dir




      :rtype: `string`







      .. versionadded:: 4.1/wxWidgets-3.1.0  
     







      .. note:: 

         On Unix this (newer) method always respects the XDG base directory specification, even if :meth:`SetFileLayout`   with  ``FileLayout_XDG``   hadn't been called.  








   .. method:: GetUserLocalDataDir(self)

      Return the directory for user data files which shouldn't be shared with the other machines.                  

      This is the same as :meth:`GetUserDataDir`   for all platforms except Windows where it returns  ``"C:\Users\username\AppData\Local\appinfo"``   or   ``"C:\Documents and Settings\username\Local Settings\Application Data\appinfo"``                       

      :rtype: `string`








   .. staticmethod:: MSWGetShellDir(csidl)

      Returns location of Windows shell special folder.                  

      This function is, by definition, MSW-specific. It can be used to access pre-defined shell directories not covered by the existing methods of this class, e.g.: ::

                  if wx.Platform == '__WXMSW__':
                      # get the location of files waiting to be burned on a CD
                      cdburnArea = wx.StandardPaths.MSWGetShellDir(CSIDL_CDBURN_AREA)

                  # endif __WXMSW__






      :param `csidl`: 
      :type `csidl`: int






      :rtype: `string`



                  



      .. versionadded:: 2.9.1 
     








   .. method:: MakeConfigFileName(self, basename, conv=ConfigFileConv_Ext)

      Return the file name which would be used by :ref:`wx.FileConfig`  if it were constructed with `basename`.                  

      `conv`  is used to construct the name of the file under Unix and only matters when using the class file layout, i.e. if :meth:`SetFileLayout`   had `not`  been called with  ``FileLayout_XDG``   argument. In this case, this argument is used to determine whether to use an extension or a leading dot. When following XDG specification, the function always appends the extension, regardless of  `conv`  value. Finally, this argument is not used at all under non-Unix platforms. 

                


      :param `basename`: 
      :type `basename`: string
      :param `conv`: 
      :type `conv`: wx.StandardPaths.ConfigFileConv




      :rtype: `string`







      .. versionadded:: 4.1/wxWidgets-3.1.1  
     








   .. method:: SetFileLayout(self, layout)

      Sets the current file layout.                  

      The default layout is  ``FileLayout_Classic``   for compatibility, however newer applications are encouraged to set it to   ``FileLayout_XDG``   on program startup. 

                


      :param `layout`: 
      :type `layout`: wx.StandardPaths.FileLayout






      .. versionadded:: 4.1/wxWidgets-3.1.1  
     








   .. method:: SetInstallPrefix(self, prefix)

      Lets :ref:`wx.StandardPaths`  know about the real program installation prefix on a Unix system.                  

      By default, the value returned by :meth:`GetInstallPrefix`   is used. 

      Although under Linux systems the program prefix may usually be determined automatically, portable programs should call this function. Usually the prefix is set during program configuration if using ``GNU`` autotools and so it is enough to pass its value defined in  ``config.h``   to this function. 





      :param `prefix`: 
      :type `prefix`: string






      .. availability:: Only available for GTK.  







      .. note:: 

         This function is only available under Unix platforms (but not limited to wxGTK mentioned below).  








   .. method:: UseAppInfo(self, info)

      Controls what application information is used when constructing paths that should be unique to this program, such as the application data directory, the plugins directory on Unix, etc.                  

      Valid values for `info`  are:

      -  ``AppInfo_None:``   don't use neither application nor vendor name in the paths. 
      -  ``AppInfo_AppName:``   use the application name in the paths. 
      -  ``AppInfo_VendorName:``   use the vendor name in the paths, usually used combined with AppInfo_AppName, i.e. as::

                 info = AppInfo_AppName | AppInfo_VendorName






      By default, only the application name is used. 

                


      :param `info`: 
      :type `info`: int






      .. versionadded:: 2.9.0 
     








   .. method:: __init__(self)

      Protected default constructor.                  

      This constructor is protected in order to prevent creation of objects of this class as :meth:`Get`   should be used instead to access the unique global :ref:`wx.StandardPaths`  object of the correct type.                   





   .. attribute:: AppDocumentsDir

      See :meth:`~wx.StandardPaths.GetAppDocumentsDir`


   .. attribute:: ConfigDir

      See :meth:`~wx.StandardPaths.GetConfigDir`


   .. attribute:: DataDir

      See :meth:`~wx.StandardPaths.GetDataDir`


   .. attribute:: DocumentsDir

      See :meth:`~wx.StandardPaths.GetDocumentsDir`


   .. attribute:: ExecutablePath

      See :meth:`~wx.StandardPaths.GetExecutablePath`


   .. attribute:: InstallPrefix

      See :meth:`~wx.StandardPaths.GetInstallPrefix` and :meth:`~wx.StandardPaths.SetInstallPrefix`


   .. attribute:: LocalDataDir

      See :meth:`~wx.StandardPaths.GetLocalDataDir`


   .. attribute:: PluginsDir

      See :meth:`~wx.StandardPaths.GetPluginsDir`


   .. attribute:: ResourcesDir

      See :meth:`~wx.StandardPaths.GetResourcesDir`


   .. attribute:: TempDir

      See :meth:`~wx.StandardPaths.GetTempDir`


   .. attribute:: UserConfigDir

      See :meth:`~wx.StandardPaths.GetUserConfigDir`


   .. attribute:: UserDataDir

      See :meth:`~wx.StandardPaths.GetUserDataDir`


   .. attribute:: UserLocalDataDir

      See :meth:`~wx.StandardPaths.GetUserLocalDataDir`


.. toctree::
   :maxdepth: 1
   :hidden:

   wx.StandardPaths.ConfigFileConv.enumeration
   wx.StandardPaths.Dir.enumeration
   wx.StandardPaths.FileLayout.enumeration
   wx.StandardPaths.ResourceCat.enumeration
