Who can give me an example for wx.fileconfig on windows?

Hi, all
Who can give me an example for wx.FileConfig on windows?
I have read the relative documents, however, I still don’t clear how to create a configuration file in the directory where the App is, what is the file format? how to set the default parameters of the configuration file, and then how to read the default configuration, and how to save the user configuration.
I used Google and other ways , I couldn’t find the example I wanted.
Could anyone help me? Thank you advance.

There’s a very simple example in the demo, in the Main.py module.

Depending on the platform and how the application is installed, you may not be able to do that. Modern platforms will lock down application installation folders and not allow normal users to write files there. They will instead have some set of paths that can be used for global preferences, user preferences, etc. You can use wx.StandardPaths to get these and other paths.

It’s basically the old Windows INI file format. Python’s configparser module is another way to read/write this kind of preferences file. https://docs.python.org/3.7/library/configparser.html

Sorry, Robin, How to get the Main.py, where is it? I am using Windows 10. Not app, it is just a small script, and i am going to pack it to a exe app using pyinstaller. Thanks.

The demo can be fetched from git, or can be downloaded here: https://extras.wxpython.org/wxPython4/extras/4.0.6/

I’m not even close to being any sort of wxPython programmer. That said, it sounds like you are attempting to capture some sort of settings either directly/extracted from the window/frame (font size, etc…) or just some sort of logging info. At least that’s what I have gleaned from your question.

On windows 10 there are normally two areas that app data is normally stored “C:\users\username\AppData\roaming” or “C:\users\username\AppData\local” to get those directories/folders I do one of the following:
dd = os.environ.get(“APPDATA”) or dd = os.environ.get(“LOCALAPPDATA”)
The above will provide the correct location to store the file. I recently discovered that the roaming directory is encrypted and of course is used with a roaming login on windows 10. If you are store more than a little bit of data you might consider using sqlite3 and create a DB.