Package wx :: Class ConfigBase
[frames | no frames]

Type ConfigBase

object --+
         |
        ConfigBase

Known Subclasses:
Config, FileConfig

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.Config or wx.FileConfig.

wx.ConfigBase organizes the items in a tree-like structure, modeled after the Unix/Dos filesystem. There are groups that act like directories and entries, key/value pairs that act like files. There is always one current group given by the current path. As in the file system case, to specify a key in the config class you must use a path to it. Config classes also support the notion of the current group, which makes it possible to use relative paths.

Keys are pairs "key_name = value" where value may be of string, integer floating point or boolean, you can not store binary data without first encoding it as a string. For performance reasons items should be kept small, no more than a couple kilobytes.


Method Summary
  __init__(self)
  __del__(self)
ConfigBase Create()
Create and return a new global config object. (Static method)
bool DeleteAll(self)
Delete the whole underlying object (disk file, registry key, ...) primarly intended for use by deinstallation routine.
bool DeleteEntry(self, key, deleteGroupIfEmpty)
Deletes the specified entry and the group it belongs to if it was the last key in it and the second parameter is True
bool DeleteGroup(self, key)
Delete the group (with all subgroups)
  DontCreateOnDemand()
Should Get() try to create a new log object if there isn't a current one? (Static method)
bool Exists(self, name)
Returns True if either a group or an entry with a given name exists
String ExpandEnvVars(self, str)
Expand any environment variables in str and return the result
bool Flush(self, currentOnly)
permanently writes all changes
ConfigBase Get(createOnDemand)
Returns the current global config object, creating one if neccessary. (Static method)
String GetAppName(self)
int GetEntryType(self, name)
Get the type of the entry.
(more, value, index) GetFirstEntry()
Allows enumerating the entries in the current group in a config object.
(more, value, index) GetFirstGroup()
Allows enumerating the subgroups in a config object.
(more, value, index) GetNextEntry(index)
Allows enumerating the entries in the current group in a config object.
(more, value, index) GetNextGroup(index)
Allows enumerating the subgroups in a config object.
size_t GetNumberOfEntries(self, recursive)
Get the number of entries in the current group, with or without its subgroups.
size_t GetNumberOfGroups(self, recursive)
Get the number of subgroups in the current group, with or without its subgroups.
String GetPath(self)
Retrieve the current path (always as absolute path)
long GetStyle(self)
String GetVendorName(self)
bool HasEntry(self, name)
Returns True if the entry by this name exists
bool HasGroup(self, name)
Returns True if the group by this name exists
bool IsExpandingEnvVars(self)
Are we currently expanding environment variables?
bool IsRecordingDefaults(self)
Are we currently recording default values?
String Read(self, key, defaultVal)
Returns the value of key if it exists, defaultVal otherwise.
bool ReadBool(self, key, defaultVal)
Returns the value of key if it exists, defaultVal otherwise.
double ReadFloat(self, key, defaultVal)
Returns the value of key if it exists, defaultVal otherwise.
long ReadInt(self, key, defaultVal)
Returns the value of key if it exists, defaultVal otherwise.
bool RenameEntry(self, oldName, newName)
Rename an entry.
bool RenameGroup(self, oldName, newName)
Rename a group.
ConfigBase Set(config)
Sets the global config object (the one returned by Get) and returns a reference to the previous global config object. (Static method)
  SetAppName(self, appName)
  SetExpandEnvVars(self, doIt)
We can automatically expand environment variables in the config entries this option is on by default, you can turn it on/off at any time)
  SetPath(self, path)
Set current path: if the first character is '/', it's the absolute path, otherwise it's a relative path.
  SetRecordDefaults(self, doIt)
Set whether the config objec should record default values.
  SetStyle(self, style)
  SetVendorName(self, vendorName)
bool Write(self, key, value)
write the value (return True on success)
bool WriteBool(self, key, value)
write the value (return True on success)
bool WriteFloat(self, key, value)
write the value (return True on success)
bool WriteInt(self, key, value)
write the value (return True on success)

Property Summary
  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
  thisown: The membership flag
  VendorName: See GetVendorName and SetVendorName

Class Variable Summary
int Type_Boolean = 2                                                                     
int Type_Float = 4                                                                     
int Type_Integer = 3                                                                     
int Type_String = 1                                                                     
int Type_Unknown = 0                                                                     

Instance Method Details

DeleteAll(self)

Delete the whole underlying object (disk file, registry key, ...) primarly intended for use by deinstallation routine.

Returns:
bool

DeleteEntry(self, 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
           (type=String)

deleteGroupIfEmpty
           (type=bool)

Returns:
bool

DeleteGroup(self, key)

Delete the group (with all subgroups)

Parameters:
key
           (type=String)

Returns:
bool

Exists(self, name)

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

Parameters:
name
           (type=String)

Returns:
bool

ExpandEnvVars(self, str)

Expand any environment variables in str and return the result

Parameters:
str
           (type=String)

Returns:
String

Flush(self, currentOnly=False)

permanently writes all changes

Parameters:
currentOnly
           (type=bool)

Returns:
bool

GetEntryType(self, name)

Get the type of the entry. Returns one of the wx.Config.Type_XXX values.

Parameters:
name
           (type=String)

Returns:
int

GetFirstEntry()

Allows enumerating the entries in the current group in a config object. Returns a tuple containing a flag indicating there are more items, the name of the current item, and an index to pass to GetNextGroup to fetch the next item.

Returns:
(more, value, index)

GetFirstGroup()

Allows enumerating the subgroups in a config object. Returns a tuple containing a flag indicating there are more items, the name of the current item, and an index to pass to GetNextGroup to fetch the next item.

Returns:
(more, value, index)

GetNextEntry(index)

Allows enumerating the entries in the current group in a config object. Returns a tuple containing a flag indicating there are more items, the name of the current item, and an index to pass to GetNextGroup to fetch the next item.

Parameters:
index
           (type=long)

Returns:
(more, value, index)

GetNextGroup(index)

Allows enumerating the subgroups in a config object. Returns a tuple containing a flag indicating there are more items, the name of the current item, and an index to pass to GetNextGroup to fetch the next item.

Parameters:
index
           (type=long)

Returns:
(more, value, index)

GetNumberOfEntries(self, recursive=False)

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

Parameters:
recursive
           (type=bool)

Returns:
size_t

GetNumberOfGroups(self, recursive=False)

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

Parameters:
recursive
           (type=bool)

Returns:
size_t

GetPath(self)

Retrieve the current path (always as absolute path)

Returns:
String

HasEntry(self, name)

Returns True if the entry by this name exists

Parameters:
name
           (type=String)

Returns:
bool

HasGroup(self, name)

Returns True if the group by this name exists

Parameters:
name
           (type=String)

Returns:
bool

IsExpandingEnvVars(self)

Are we currently expanding environment variables?

Returns:
bool

IsRecordingDefaults(self)

Are we currently recording default values?

Returns:
bool

Read(self, key, defaultVal=EmptyString)

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

Parameters:
key
           (type=String)

defaultVal
           (type=String)

Returns:
String

ReadBool(self, key, defaultVal=False)

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

Parameters:
key
           (type=String)

defaultVal
           (type=bool)

Returns:
bool

ReadFloat(self, key, defaultVal=0.0)

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

Parameters:
key
           (type=String)

defaultVal
           (type=double)

Returns:
double

ReadInt(self, key, defaultVal=0)

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

Parameters:
key
           (type=String)

defaultVal
           (type=long)

Returns:
long

RenameEntry(self, oldName, newName)

Rename an entry. Returns False on failure (probably because the new name is already taken by an existing entry)

Parameters:
oldName
           (type=String)

newName
           (type=String)

Returns:
bool

RenameGroup(self, oldName, newName)

Rename a group. Returns False on failure (probably because the new name is already taken by an existing entry)

Parameters:
oldName
           (type=String)

newName
           (type=String)

Returns:
bool

SetExpandEnvVars(self, doIt=True)

We can automatically expand environment variables in the config entries this option is on by default, you can turn it on/off at any time)

Parameters:
doIt
           (type=bool)

SetPath(self, path)

Set current path: if the first character is '/', it's the absolute path, otherwise it's a relative path. '..' is supported. If the strPath doesn't exist it is created.

Parameters:
path
           (type=String)

SetRecordDefaults(self, doIt=True)

Set whether the config objec should record default values.

Parameters:
doIt
           (type=bool)

Write(self, key, value)

write the value (return True on success)

Parameters:
key
           (type=String)

value
           (type=String)

Returns:
bool

WriteBool(self, key, value)

write the value (return True on success)

Parameters:
key
           (type=String)

value
           (type=bool)

Returns:
bool

WriteFloat(self, key, value)

write the value (return True on success)

Parameters:
key
           (type=String)

value
           (type=double)

Returns:
bool

WriteInt(self, key, value)

write the value (return True on success)

Parameters:
key
           (type=String)

value
           (type=long)

Returns:
bool

Static Method Details

Create()

Create and return a new global config object. This function will create the "best" implementation of wx.Config available for the current platform.

Returns:
ConfigBase

DontCreateOnDemand()

Should Get() try to create a new log object if there isn't a current one?

Get(createOnDemand=True)

Returns the current global config object, creating one if neccessary.

Parameters:
createOnDemand
           (type=bool)

Returns:
ConfigBase

Set(config)

Sets the global config object (the one returned by Get) and returns a reference to the previous global config object.

Parameters:
config
           (type=ConfigBase)

Returns:
ConfigBase

Property Details

AppName

See GetAppName and SetAppName

Get Method:
GetAppName(self)
Set Method:
SetAppName(self, appName)

EntryType

See GetEntryType

Get Method:
GetEntryType(self, name)

FirstEntry

See GetFirstEntry

Get Method:
GetFirstEntry()

FirstGroup

See GetFirstGroup

Get Method:
GetFirstGroup()

NextEntry

See GetNextEntry

Get Method:
GetNextEntry(index)

NextGroup

See GetNextGroup

Get Method:
GetNextGroup(index)

NumberOfEntries

See GetNumberOfEntries

Get Method:
GetNumberOfEntries(self, recursive)

NumberOfGroups

See GetNumberOfGroups

Get Method:
GetNumberOfGroups(self, recursive)

Path

See GetPath and SetPath

Get Method:
GetPath(self)
Set Method:
SetPath(self, path)

Style

See GetStyle and SetStyle

Get Method:
GetStyle(self)
Set Method:
SetStyle(self, style)

thisown

The membership flag

VendorName

See GetVendorName and SetVendorName

Get Method:
GetVendorName(self)
Set Method:
SetVendorName(self, vendorName)

Class Variable Details

Type_Boolean

Type:
int
Value:
2                                                                     

Type_Float

Type:
int
Value:
4                                                                     

Type_Integer

Type:
int
Value:
3                                                                     

Type_String

Type:
int
Value:
1                                                                     

Type_Unknown

Type:
int
Value:
0                                                                     

Generated by Epydoc 2.1.20050511.rpd on Thu Mar 22 12:12:14 2007 http://epydoc.sf.net