GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Table of Contents
  • wx.ConfigPathChanger
  • Show Source
  • index
  • modules
  • next
  • previous
  • Home
  • Gallery
  • wx

This view

  • Original page
  • New address

GeezerVison is showing docs.wxpython.org — wx.ConfigPathChanger — wxPython 4.3.2 Docs

phoenix_title wx.ConfigPathChanger¶

A handy little class which changes the current path in a Config object and restores it in dtor.

Declaring a local variable of this type, it’s possible to work in a specific directory and ensure that the path is automatically restored when the function returns.

For example:

# this function loads some settings from the given wx.Config object
# the path selected inside it is left unchanged
def LoadMySettings(config):

    changer = wx.ConfigPathChanger(config, "/Foo/Data/SomeString")

    strs = config.Read("SomeString")

    if not strs:
        wx.LogError("Couldn't read SomeString!")
        return False

    # NOTE: without wx.ConfigPathChanger it would be easy to forget to
    #       set the old path back into the wx.Config object before this return!


    # do something useful with SomeString...

    return True  # again: wx.ConfigPathChanger dtor will restore the original wx.Config path

class_hierarchy Class Hierarchy¶

Inheritance diagram for class ConfigPathChanger:

Inheritance diagram of ConfigPathChanger


method_summary Methods Summary¶

__init__

Changes the path of the given wx.ConfigBase object so that the key strEntry is accessible (for read or write).

Name

Returns the name of the key which was passed to the constructor.

UpdateIfDeleted

This method must be called if the original path inside the Config object (i.e.

__enter__

__exit__


api Class API¶

class wx.ConfigPathChanger(object)¶

Possible constructors:

ConfigPathChanger(pContainer, strEntry) -> None

A handy little class which changes the current path in a Config object and restores it in dtor.


Methods¶

__init__(self, pContainer, strEntry)¶

Changes the path of the given wx.ConfigBase object so that the key strEntry is accessible (for read or write).

In other words, the constructor uses wx.ConfigBase.SetPath with everything which precedes the last slash of strEntry, so that:

wx.ConfigPathChanger(wx.ConfigBase.Get(), "/MyProgram/SomeKeyName")

has the same effect of:

wx.ConfigPathChanger(wx.ConfigBase.Get(), "/MyProgram/")
Parameters:
  • pContainer (wx.ConfigBase)

  • strEntry (string)

Return type:

None



Name(self)¶

Returns the name of the key which was passed to the constructor.

The “name” is just anything which follows the last slash of the string given to the constructor.

Return type:

str



UpdateIfDeleted(self)¶

This method must be called if the original path inside the Config object (i.e.

the current path at the moment of creation of this wx.ConfigPathChanger object) could have been deleted, thus preventing wx.ConfigPathChanger from restoring the not existing (any more) path.

If the original path doesn’t exist any more, the path will be restored to the deepest still existing component of the old path.

Return type:

None



__enter__(self)¶


__exit__(self, exc_type, exc_val, exc_tb)¶
© Copyright 2012-2026, The wxPython Team. Created using Sphinx 9.1.0 and the python-docs-theme.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.