wx.ConfigBase

Inheritance diagram for 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

Class API

Methods

__init__()
No docstrings found for this 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


DeleteAll()

Delete the whole underlying object (disk file, registry key, ...). Primarly for use by uninstallation routine.


Returns:

bool


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


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


DontCreateOnDemand()
Calling this function will prevent 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.

Exists(strName)

returns True if either a group or an entry with a given name exists

Parameters:

  • strName (string)

Returns:

bool


ExpandEnvVars(str)

Expand any environment variables in str and return the result

Parameters:

  • str (string)

Returns:

string


Flush(bCurrentOnly=False)

permanently writes all changes (otherwise, they’re only written from object’s destructor)

Parameters:

  • bCurrentOnly (bool)

Returns:

bool


Get(createOnDemand=True)

Get the current config object. If there is no current object and CreateOnDemand is True, creates one (using Create) unless DontCreateOnDemand was called previously.

Parameters:

  • createOnDemand (bool)

Returns:

wx.ConfigBase


GetAppName()

Returns the application name.


Returns:

string


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 () 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


GetFirstEntry()

Gets the first entry.


Returns:

bool


GetFirstGroup()

Gets the first group.


Returns:

bool


GetNextEntry(str)

Gets the next entry.

Parameters:

  • str (string)

Returns:

bool


GetNextGroup(str)

Gets the next group.

Parameters:

  • str (string)

Returns:

bool


GetNumberOfEntries(bRecursive=False)

Parameters:

  • bRecursive (bool)

Returns:

uint


GetNumberOfGroups(bRecursive=False)

Get number of entries/subgroups in the current group, with or without its subgroups.

Parameters:

  • bRecursive (bool)

Returns:

uint


GetPath()

Retrieve the current path (always as absolute path).


Returns:

string


GetStyle()
No docstrings found for this method.

GetVendorName()

Returns the vendor name.


Returns:

string


HasEntry(strName)

returns True if the entry by this name exists.

Parameters:

  • strName (string)

Returns:

bool


HasGroup(strName)

returns True if the group by this name exists.

Parameters:

  • strName (string)

Returns:

bool


IsExpandingEnvVars()

Returns True if we are expanding environment variables in key values.


Returns:

bool


IsRecordingDefaults()

Returns True if we are writing defaults back to the config file.


Returns:

bool


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


ReadBool(key, defaultVal=False)

Returns the value of key if it exists, defaultVal otherwise.

Parameters:

  • key (string)
  • defaultVal (bool)

Returns:

bool


ReadFloat(key, defaultVal=0.0)

Returns the value of key if it exists, defaultVal otherwise.

Parameters:

  • key (string)
  • defaultVal (double)

Returns:

double


ReadInt(key, defaultVal=0)

Returns the value of key if it exists, defaultVal otherwise.

Parameters:

  • key (string)
  • defaultVal (long)

Returns:

long


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


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


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:


Returns:

wx.ConfigBase


SetAppName(appName)

Parameters:

  • appName (string)

SetExpandEnvVars(bDoIt=True)

Determine whether we wish to expand environment variables in key values.

Parameters:

  • bDoIt (bool)

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)

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)

SetStyle(style)

Parameters:

  • style (long)

SetVendorName(vendorName)

Parameters:

  • vendorName (string)

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


WriteBool(key, value)

write the value (return True on success)

Parameters:

  • key (string)
  • value (bool)

Returns:

bool


WriteFloat(key, value)

write the value (return True on success)

Parameters:

  • key (string)
  • value (double)

Returns:

bool


WriteInt(key, value)

write the value (return True on success)

Parameters:

  • key (string)
  • value (long)

Returns:

bool


Properties

AppName
See GetAppName and SetAppName
EntryType
See GetEntryType
FirstEntry
See GetFirstEntry
FirstGroup
See GetFirstGroup
NextEntry
See GetNextEntry
NextGroup
See GetNextGroup
NumberOfEntries
See GetNumberOfEntries
NumberOfGroups
See GetNumberOfGroups
Path
See GetPath and SetPath
Style
See GetStyle and SetStyle
VendorName
See GetVendorName and SetVendorName