************* wx.ConfigBase ************* Inheritance diagram for `wx.ConfigBase`: | .. inheritance-diagram:: wx.ConfigBase | Description =========== `wx.ConfigBase` class defines the basic interface of all config classes. It can not be used by itself (it is an abstract base class) and you will always use one of its derivations: `wx.FileConfig `_ , `wx.RegConfig` or any other. However, usually you don't even need to know the precise nature of the class you're working with but you would just use the `wx.ConfigBase` methods. This allows you to write the same code regardless of whether you're working with the registry under Win32 or text-based config files under Unix (or even Windows 3.1 .INI files if you're really unlucky). To make writing the portable code even easier, wxWidgets provides a typedef `wx.Config` which is mapped onto the native `wx.ConfigBase` implementation on the given platform: i.e. `wx.RegConfig` under Win32 and `wx.FileConfig` otherwise. Here is how you would typically use this class:: # using wx.Config instead of writing wx.FileConfig enhances # portability of the code config = wx.Config("MyAppName") strs = config.Read("LastPrompt") if strs: # last prompt was found in the config file/registry and its value is now # in strs DoSomething(strs) else: NoString() Known Subclasses ^^^^^^^^^^^^^^^^ `wx.Config `_, `wx.FileConfig `_ Methods Summary ^^^^^^^^^^^^^^^ * `__init__ <#__init__>`_ * `Create <#Create>`_ * `DeleteAll <#DeleteAll>`_ * `DeleteEntry <#DeleteEntry>`_ * `DeleteGroup <#DeleteGroup>`_ * `DontCreateOnDemand <#DontCreateOnDemand>`_ * `Exists <#Exists>`_ * `ExpandEnvVars <#ExpandEnvVars>`_ * `Flush <#Flush>`_ * `Get <#Get>`_ * `GetAppName <#GetAppName>`_ * `GetEntryType <#GetEntryType>`_ * `GetFirstEntry <#GetFirstEntry>`_ * `GetFirstGroup <#GetFirstGroup>`_ * `GetNextEntry <#GetNextEntry>`_ * `GetNextGroup <#GetNextGroup>`_ * `GetNumberOfEntries <#GetNumberOfEntries>`_ * `GetNumberOfGroups <#GetNumberOfGroups>`_ * `GetPath <#GetPath>`_ * `GetStyle <#GetStyle>`_ * `GetVendorName <#GetVendorName>`_ * `HasEntry <#HasEntry>`_ * `HasGroup <#HasGroup>`_ * `IsExpandingEnvVars <#IsExpandingEnvVars>`_ * `IsRecordingDefaults <#IsRecordingDefaults>`_ * `Read <#Read>`_ * `ReadBool <#ReadBool>`_ * `ReadFloat <#ReadFloat>`_ * `ReadInt <#ReadInt>`_ * `RenameEntry <#RenameEntry>`_ * `RenameGroup <#RenameGroup>`_ * `Set <#Set>`_ * `SetAppName <#SetAppName>`_ * `SetExpandEnvVars <#SetExpandEnvVars>`_ * `SetPath <#SetPath>`_ * `SetRecordDefaults <#SetRecordDefaults>`_ * `SetStyle <#SetStyle>`_ * `SetVendorName <#SetVendorName>`_ * `Write <#Write>`_ * `WriteBool <#WriteBool>`_ * `WriteFloat <#WriteFloat>`_ * `WriteInt <#WriteInt>`_ Properties Summary ^^^^^^^^^^^^^^^^^^ * `AppName <#AppName>`_ * `EntryType <#EntryType>`_ * `FirstEntry <#FirstEntry>`_ * `FirstGroup <#FirstGroup>`_ * `NextEntry <#NextEntry>`_ * `NextGroup <#NextGroup>`_ * `NumberOfEntries <#NumberOfEntries>`_ * `NumberOfGroups <#NumberOfGroups>`_ * `Path <#Path>`_ * `Style <#Style>`_ * `VendorName <#VendorName>`_ Class API ========= Methods ^^^^^^^ .. method:: __init__() `No docstrings found for this method.` -------- .. method:: Create() Create a new config object: this function will create the "best" implementation of `wx.Config` available for the current platform. It returns the created object and also sets it as the current one. | **Returns:** `wx.ConfigBase `_ -------- .. method:: DeleteAll() Delete the whole underlying object (disk file, registry key, ...). Primarly for use by uninstallation routine. | **Returns:** `bool` -------- .. method:: DeleteEntry(key, deleteGroupIfEmpty=True) Deletes the specified entry and the group it belongs to if it was the last key in it and the second parameter is ``True``. **Parameters:** * `key` (string) * `deleteGroupIfEmpty` (bool) | **Returns:** `bool` -------- .. method:: DeleteGroup(key) Delete the group (with all subgroups). If the current path is under the group being deleted it is changed to its deepest still existing component. E.g. if the current path is ``/A/B/C/D`` and the group ``C`` is deleted the path becomes ``/A/B``. **Parameters:** * `key` (string) | **Returns:** `bool` -------- .. method:: DontCreateOnDemand() Calling this function will prevent `Get <#Get>`_ () from automatically creating a new config object if the current one is ``None``. It might be useful to call it near the program end to prevent "accidental" creation of a new config object. -------- .. method:: Exists(strName) returns ``True`` if either a group or an entry with a given name exists **Parameters:** * `strName` (string) | **Returns:** `bool` -------- .. method:: ExpandEnvVars(str) Expand any environment variables in `str` and return the result **Parameters:** * `str` (string) | **Returns:** `string` -------- .. method:: Flush(bCurrentOnly=False) permanently writes all changes (otherwise, they're only written from object's destructor) **Parameters:** * `bCurrentOnly` (bool) | **Returns:** `bool` -------- .. method:: Get(createOnDemand=True) Get the current config object. If there is no current object and *CreateOnDemand* is ``True``, creates one (using `Create <#Create>`_) unless `DontCreateOnDemand <#DontCreateOnDemand>`_ was called previously. **Parameters:** * `createOnDemand` (bool) | **Returns:** `wx.ConfigBase `_ -------- .. method:: GetAppName() Returns the application name. | **Returns:** `string` -------- .. method:: GetEntryType(name) Returns the type of the given entry or *Unknown* if the entry doesn't exist. This function should be used to decide which version of `Read <#Read>`_ () should be used because some of `wx.Config` implementations will complain about type mismatch otherwise: e.g., an attempt to read a string value from an integer key with `wx.RegConfig` will fail. **Parameters:** * `name` (string) | **Returns:** `int` -------- .. method:: GetFirstEntry() Gets the first entry. | **Returns:** `bool` -------- .. method:: GetFirstGroup() Gets the first group. | **Returns:** `bool` -------- .. method:: GetNextEntry(str) Gets the next entry. **Parameters:** * `str` (string) | **Returns:** `bool` -------- .. method:: GetNextGroup(str) Gets the next group. **Parameters:** * `str` (string) | **Returns:** `bool` -------- .. method:: GetNumberOfEntries(bRecursive=False) | **Parameters:** * `bRecursive` (bool) | **Returns:** `uint` -------- .. method:: GetNumberOfGroups(bRecursive=False) Get number of entries/subgroups in the current group, with or without its subgroups. **Parameters:** * `bRecursive` (bool) | **Returns:** `uint` -------- .. method:: GetPath() Retrieve the current path (always as absolute path). | **Returns:** `string` -------- .. method:: GetStyle() `No docstrings found for this method.` -------- .. method:: GetVendorName() Returns the vendor name. | **Returns:** `string` -------- .. method:: HasEntry(strName) returns ``True`` if the entry by this name exists. **Parameters:** * `strName` (string) | **Returns:** `bool` -------- .. method:: HasGroup(strName) returns ``True`` if the group by this name exists. **Parameters:** * `strName` (string) | **Returns:** `bool` -------- .. method:: IsExpandingEnvVars() Returns ``True`` if we are expanding environment variables in key values. | **Returns:** `bool` -------- .. method:: IsRecordingDefaults() Returns ``True`` if we are writing defaults back to the config file. | **Returns:** `bool` -------- .. method:: Read(key, defaultVal="") Reads a bool value, returning ``True`` if the value was found. If the value was not found, `defaultVal` is used instead. **Parameters:** * `key` (string) * `defaultVal` (string) | **Returns:** `bool` -------- .. method:: ReadBool(key, defaultVal=False) Returns the value of key if it exists, `defaultVal` otherwise. **Parameters:** * `key` (string) * `defaultVal` (bool) | **Returns:** `bool` -------- .. method:: ReadFloat(key, defaultVal=0.0) Returns the value of key if it exists, `defaultVal` otherwise. **Parameters:** * `key` (string) * `defaultVal` (double) | **Returns:** `double` -------- .. method:: ReadInt(key, defaultVal=0) Returns the value of key if it exists, `defaultVal` otherwise. **Parameters:** * `key` (string) * `defaultVal` (long) | **Returns:** `long` -------- .. method:: RenameEntry(oldName, newName) Renames an entry in the current group. The entries names (both the old and the new one) shouldn't contain backslashes, i.e. only simple names and not arbitrary paths are accepted by this function. Returns ``False`` if `oldName` doesn't exist or if `newName` already exists. **Parameters:** * `oldName` (string) * `newName` (string) | **Returns:** `bool` -------- .. method:: RenameGroup(oldName, newName) Renames a subgroup of the current group. The subgroup names (both the old and the new one) shouldn't contain backslashes, i.e. only simple names and not arbitrary paths are accepted by this function. Returns ``False`` if `oldName` doesn't exist or if `newName` already exists. **Parameters:** * `oldName` (string) * `newName` (string) | **Returns:** `bool` -------- .. method:: Set(pConfig) Sets the config object as the current one, returns the pointer to the previous current object (both the parameter and returned value may be ``None``) **Parameters:** * `pConfig` (`wx.ConfigBase `_) | **Returns:** `wx.ConfigBase `_ -------- .. method:: SetAppName(appName) | **Parameters:** * `appName` (string) -------- .. method:: SetExpandEnvVars(bDoIt=True) Determine whether we wish to expand environment variables in key values. **Parameters:** * `bDoIt` (bool) -------- .. method:: SetPath(strPath) Set current path: if the first character is '/', it is the absolute path, otherwise it is a relative path. '..' is supported. If `strPath` doesn't exist it is created. **Parameters:** * `strPath` (string) -------- .. method:: SetRecordDefaults(bDoIt=True) Sets whether defaults are recorded to the config file whenever an attempt to read the value which is not present in it is done. If on (default is off) all default values for the settings used by the program are written back to the config file. This allows the user to see what config options may be changed and is probably useful only for `wx.FileConfig`. **Parameters:** * `bDoIt` (bool) -------- .. method:: SetStyle(style) | **Parameters:** * `style` (long) -------- .. method:: SetVendorName(vendorName) | **Parameters:** * `vendorName` (string) -------- .. method:: Write(key, value) These functions write the specified value to the config file and return ``True`` on success. **Parameters:** * `key` (string) * `value` (string) | **Returns:** `bool` -------- .. method:: WriteBool(key, value) write the value (return ``True`` on success) **Parameters:** * `key` (string) * `value` (bool) | **Returns:** `bool` -------- .. method:: WriteFloat(key, value) write the value (return ``True`` on success) **Parameters:** * `key` (string) * `value` (double) | **Returns:** `bool` -------- .. method:: WriteInt(key, value) write the value (return ``True`` on success) **Parameters:** * `key` (string) * `value` (long) | **Returns:** `bool` -------- Properties ^^^^^^^^^^ .. attribute:: AppName See `GetAppName <#GetAppName>`_ and `SetAppName <#SetAppName>`_ .. attribute:: EntryType See `GetEntryType <#GetEntryType>`_ .. attribute:: FirstEntry See `GetFirstEntry <#GetFirstEntry>`_ .. attribute:: FirstGroup See `GetFirstGroup <#GetFirstGroup>`_ .. attribute:: NextEntry See `GetNextEntry <#GetNextEntry>`_ .. attribute:: NextGroup See `GetNextGroup <#GetNextGroup>`_ .. attribute:: NumberOfEntries See `GetNumberOfEntries <#GetNumberOfEntries>`_ .. attribute:: NumberOfGroups See `GetNumberOfGroups <#GetNumberOfGroups>`_ .. attribute:: Path See `GetPath <#GetPath>`_ and `SetPath <#SetPath>`_ .. attribute:: Style See `GetStyle <#GetStyle>`_ and `SetStyle <#SetStyle>`_ .. attribute:: VendorName See `GetVendorName <#GetVendorName>`_ and `SetVendorName <#SetVendorName>`_