GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing docs.wxpython.org — wx.ConfigBase — wxPython 4.3.2 Docs
|
This is the default and only constructor of the wx.ConfigBase class, and derived classes. |
|
Create a new config object and sets it as the current one. |
|
Delete the whole underlying object (disk file, registry key, …). |
|
Deletes the specified entry and the group it belongs to if it was the last key in it and the second parameter is |
|
Delete the group (with all subgroups). |
|
Calling this function will prevent ` |
|
Permanently writes all changes (otherwise, they’re only written from object’s destructor). |
|
Get the current config object. |
|
Returns the application name. |
|
Returns the type of the given entry or Unknown if the entry doesn’t exist. |
|
GetFirstEntry() . (more, value, index) |
|
GetFirstGroup() . (more, value, index) |
|
GetNextEntry() . (more, value, index) |
|
GetNextGroup(long index) . (more, value, index) |
|
Get number of entries in the current group. |
|
Get number of entries/subgroups in the current group, with or without its subgroups. |
|
Retrieve the current path (always as absolute path). |
|
Returns the vendor name. |
|
Returns |
|
Returns |
|
Another version of |
|
Reads a float value from the key and returns it. |
|
Reads a long value from the key and returns it. |
|
Reads a 64-bit long long value from the key and returns it. |
|
Renames an entry in the current group. |
|
Renames a subgroup of the current group. |
|
Sets the config object as the current one, returns the pointer to the previous current object (both the parameter and returned value may be nullptr). |
|
Determine whether we wish to expand environment variables in key values. |
|
Set current path: if the first character is ‘/’, it is the absolute path, otherwise it is a relative path. |
|
Sets whether defaults are recorded to the config file whenever an attempt to read the value which is not present in it is done. |
|
Writes the String value to the config file and returns |
|
Properties Summary¶See |
|
See |
|
See |
|
See |
Class API¶Possible constructors:
ConfigBase(appName='', vendorName='', localFilename='', globalFilename='', style=0) -> None
ConfigBase defines the basic interface of all config classes.
This is the default and only constructor of the wx.ConfigBase class, and derived classes.
appName (string) – The application name. If this is empty, the class will normally use wx.App.GetAppName to set it. The application name is used in the registry key on Windows, and can be used to deduce the local filename parameter if that is missing.
vendorName (string) – The vendor name. If this is empty, it is assumed that no vendor name is wanted, if this is optional for the current config class. The vendor name is appended to the application name for RegConfig .
localFilename (string) – Some config classes require a local filename. If this is not present, but required, the application name will be used instead.
globalFilename (string) – Some config classes require a global filename. If this is not present, but required, the application name will be used instead.
style (long) – Can be one of CONFIG_USE_LOCAL_FILE and CONFIG_USE_GLOBAL_FILE .
The style interpretation depends on the config class and is ignored by some implementations. For wx.FileConfig, these styles determine whether a local or global config file is created or used: if CONFIG_USE_GLOBAL_FILE is used, then settings are read from the global config file and if CONFIG_USE_LOCAL_FILE is used, settings are read from and written to local config file (if they are both set, global file is read first, then local file, overwriting global settings). If the flag is present but the parameter is empty, the parameter will be set to a default. If the parameter is present but the style flag not, the relevant flag will be added to the style. For RegConfig , the GLOBAL flag refers to the HKLM key while LOCAL one is for the usual HKCU one.
For wx.FileConfig you can also add CONFIG_USE_RELATIVE_PATH by logically or’ing it to either of the _FILE options to tell wx.FileConfig to use relative instead of absolute paths.
On Unix-like systems, the default local configuration file is ~/.appname unless wx.StandardPaths.SetFileLayout is called with wx.StandardPaths.FileLayout_XDG parameter in which case the default becomes ~/.config/appname.conf .
Note that this default path may be also used as user data directory (see wx.StandardPaths.GetUserDataDir ) if the application has several data files. In this case it is recommended to use CONFIG_USE_XDG flag (available since wxWidgets 3.3.0) and/or older CONFIG_USE_SUBDIR (available since 2.8.2) to change the default local configuration file location.
For wx.FileConfig, you can also add CONFIG_USE_NO_ESCAPE_CHARACTERS which will turn off character escaping for the values of entries stored in the config file: for example a foo key with some backslash characters will be stored as “foo=C:\mydir” instead of the usual storage of “foo=C:\\mydir”.
The CONFIG_USE_NO_ESCAPE_CHARACTERS style can be helpful if your config file must be read or written to by a non-wxWidgets program (which might not understand the escape characters). Note, however, that if CONFIG_USE_NO_ESCAPE_CHARACTERS style is used, it is now your application’s responsibility to ensure that there is no newline or other illegal characters in a value, before writing that value to the file.
This parameter is only used by wx.FileConfig when compiled in Unicode mode. It specifies the encoding in which the configuration file is written.
None
Note
By default, environment variable expansion is on and recording defaults is off.
Create a new config object and sets it as the current one.
This function will create the most appropriate implementation of Config available for the current platform. By default this means that the system registry will be used for storing the configuration information under MSW and a file under the user home directory (see wx.StandardPaths.GetUserConfigDir ) elsewhere.
If you prefer to use the configuration files everywhere, you can define USE_CONFIG_NATIVE to 0 when compiling wxWidgets. Or you can simply always create wx.FileConfig explicitly.
Finally, if you want to create a custom Config subclass you may change this function behaviour by overriding wx.AppTraits.CreateConfig to create it. An example when this could be useful could be an application which could be installed either normally (in which case the default behaviour of using RegConfig is appropriate) or in a “portable” way in which case a wx.FileConfig with a file in the program directory would be used and the choice would be done in CreateConfig() at run-time.
Delete the whole underlying object (disk file, registry key, …).
Primarily for use by uninstallation routine.
bool
Deletes the specified entry and the group it belongs to if it was the last key in it and the second parameter is True.
key (string)
bDeleteGroupIfEmpty (bool)
bool
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" .
key (string)
bool
Calling this function will prevent ` Get ` from automatically creating a new config object if the current one is nullptr.
It might be useful to call it near the program end to prevent “accidental” creation of a new config object.
None
strName (string)
bool
True if either a group or an entry with a given name exists.
Permanently writes all changes (otherwise, they’re only written from object’s destructor).
bCurrentOnly (bool)
bool
Get the current config object.
If there is no current object and CreateOnDemand is True, this creates one (using Create ) unless DontCreateOnDemand was called previously.
CreateOnDemand (bool)
Returns the application name.
str
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 Config implementations will complain about type mismatch otherwise: e.g., an attempt to read a string value from an integer key with RegConfig will fail.
name (string)
GetFirstEntry() . (more, value, index)
Allows enumerating the entries in the current group in a config object. Returns a tuple containing a flag indicating if there are more items, the name of the current item, and an index to pass to GetNextEntry to fetch the next item.
Any
GetFirstGroup() . (more, value, index)
Allows enumerating the subgroups in a config object. Returns a tuple containing a flag indicating if there are more items, the name of the current item, and an index to pass to GetNextGroup to fetch the next item.
Any
GetNextEntry() . (more, value, index)
Allows enumerating the entries in the current group in a config object. Returns a tuple containing a flag indicating if there are more items, the name of the current item, and an index to pass to GetNextEntry to fetch the next item.
Any
GetNextGroup(long index) . (more, value, index)
Allows enumerating the subgroups in a config object. Returns a tuple containing a flag indicating if there are more items, the name of the current item, and an index to pass to GetNextGroup to fetch the next item.
Any
Get number of entries in the current group.
bRecursive (bool)
int
Get number of entries/subgroups in the current group, with or without its subgroups.
bRecursive (bool)
int
Retrieve the current path (always as absolute path).
str
Returns the vendor name.
str
strName (string)
bool
True if the entry by this name exists.
strName (string)
bool
True if the group by this name exists.
Returns True if we are expanding environment variables in key values.
bool
Returns True if we are writing defaults back to the config file.
bool
bool
Reads a float value from the key and returns it.
defaultVal is returned if the key is not found.
key (string)
defaultVal (float)
float
float
Reads a long value from the key and returns it.
defaultVal is returned if the key is not found.
key (string)
defaultVal (long)
int
Reads a 64-bit long long value from the key and returns it.
defaultVal is returned if the key is not found.
key (string)
defaultVal (LongLong_t)
int
Added in version 4.1/wxWidgets-3.1.5.
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.
oldName (string)
newName (string)
bool
False if oldName doesn’t exist or if newName already exists.
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.
oldName (string)
newName (string)
bool
False if oldName doesn’t exist or if newName already exists.
Sets the config object as the current one, returns the pointer to the previous current object (both the parameter and returned value may be nullptr).
pConfig (wx.ConfigBase)
Determine whether we wish to expand environment variables in key values.
bDoIt (bool)
None
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.
strPath (string)
None
See also
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.
bDoIt (bool)
None
Writes the String value to the config file and returns True on success.
key (string)
value (string)
bool
bool
bool
bool
int
See GetAppName
See GetFirstEntry
See GetFirstGroup
See GetVendorName