Can't Get wx.FileConfig To Work

Hi Ira,

Ira Kaplan wrote:

Hi. I'm using wxPython 2.6.10, ActiveState Python 2.4.8 under Windows XP home edition.
I am trying to use wx.FileConfig to keep application data in a text file (not the Windows registry).

When running my sample code below I get the following error message:

Traceback (most recent call last):
  File "Config v2.py", line 27, in OnRun
    result = config.Save(configFilename) AttributeError: 'FileConfig' object has no attribute 'Save'

Yet wx.FileConfig has a Save() method. What am I doing wrong?

import wx
help(wx.FileConfig)
Doesn't show Save() but in wxPython doc it is still there?!

The following works for me on Win XP:
## # create an empty config file
        #configFilename = r'whatever path\wxConfigTesting.ini'
        configFilename = r'wxConfigTesting.ini' # on Win this goes to C:\Documents and Settings\user name
## stream = open(configFilename, "w")
## stream.close()

        # set two values and save
        config = wx.FileConfig('myApp', 'myVendor', configFilename)
        config.Write("FrameBackgroundColor", "red")
        config.Write("TextWindowBackgroundColor", "white")
        #result = config.Save(configFilename) # is in doc but not in module???!!!
        result = config.Flush()
        print result

Also, is there any sample code for using wx.FileConfig and wx.ConfigBase? I could not find anything in the wiki.

Thanks,
Ira

See you
Werner

Werner,

Thank you; I will try your solution. My guess is that the It seems the Flush( ) forces the buffer(s) to write to the file, removing the need for an explicit save.

But I am not losing my mind as one poster wrote the Save( ) method does not exist.

From the wxWidgets documentation:

      wxFileConfig::Save

*bool* *Save*(*wxOutputStream& */os/, *wxMBConv& */conv = wxConvUTF8/)

Saves all config data to the given stream, returns true if data was saved successfully or false on error.

Note the interaction of this function with the internal "dirty flag'': the data is saved unconditionally, i.e. even if the object is not dirty. However after saving it successfully, the dirty flag is reset so no changes will be written back to the file this object is associated with until you change its contents again.

Ira

Werner F. Bruhin wrote:

···

Hi Ira,

Ira Kaplan wrote:

Hi. I'm using wxPython 2.6.10, ActiveState Python 2.4.8 under Windows XP home edition.
I am trying to use wx.FileConfig to keep application data in a text file (not the Windows registry).

When running my sample code below I get the following error message:

Traceback (most recent call last):
  File "Config v2.py", line 27, in OnRun
    result = config.Save(configFilename) AttributeError: 'FileConfig' object has no attribute 'Save'

Yet wx.FileConfig has a Save() method. What am I doing wrong?

import wx
help(wx.FileConfig)
Doesn't show Save() but in wxPython doc it is still there?!

The following works for me on Win XP:
## # create an empty config file
       #configFilename = r'whatever path\wxConfigTesting.ini'
       configFilename = r'wxConfigTesting.ini' # on Win this goes to C:\Documents and Settings\user name
## stream = open(configFilename, "w")
## stream.close()

       # set two values and save
       config = wx.FileConfig('myApp', 'myVendor', configFilename)
       config.Write("FrameBackgroundColor", "red")
       config.Write("TextWindowBackgroundColor", "white")
       #result = config.Save(configFilename) # is in doc but not in module???!!!
       result = config.Flush()
       print result

Also, is there any sample code for using wx.FileConfig and wx.ConfigBase? I could not find anything in the wiki.

Thanks,
Ira

See you
Werner

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Hi Ira,

Ira Kaplan wrote:

Werner,

Thank you; I will try your solution. My guess is that the It seems the Flush( ) forces the buffer(s) to write to the file, removing the need for an explicit save.

But I am not losing my mind as one poster wrote the Save( ) method does not exist.

No, I found it there too. But if you do this

import wx
help(wx.FileConfig)

you will not see it, or if you check the new API doc you will not see it either (by the way there is a download version available for the API doc).

Hopefully Robin can shed some light on this, why it is not available

See you
Werner

Werner,

What is the location of the downloadable wxPython API doc? I could not find it on the wxPython website.

Thanks,
Ira

Werner F. Bruhin wrote:

···

Hi Ira,

Ira Kaplan wrote:

Werner,

Thank you; I will try your solution. My guess is that the It seems the Flush( ) forces the buffer(s) to write to the file, removing the need for an explicit save.

But I am not losing my mind as one poster wrote the Save( ) method does not exist.

No, I found it there too. But if you do this

import wx
help(wx.FileConfig)

you will not see it, or if you check the new API doc you will not see it either (by the way there is a download version available for the API doc).

Hopefully Robin can shed some light on this, why it is not available

See you
Werner

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org