In trying to work with wxPython to make up a small utility which I can port between Windows & Mint, I have run into a curious issue when I try to construct a directory path for my config data.
Under Windows, my usual location is %AppData%\appname
Under Mint/Linux I am using ~/home/user/.appname/
Under both systems I work in VSCode to build and debug.
In my main apps init section, I try to obtain the base path for my config directory with:
stdPth = wx.StandardPaths.Get()
# use the same path for all needs to ensure consistency
test = stdPth.GetUserDataDir()
if wx.Port == '__WXMSW__':
configDir = os.path.join(stdPth.GetUserConfigDir(), gl.globAppName )
elif wx.Port == '__WXGTK__':
configDir = stdPth.GetUserDataDir()
else:
configDir = ""
gl.globIniFileDir = configDir
if not os.path.exists(configDir):
os.makedirs(configDir)
For both systems, this gives me the path I expect:
~/home/user/.AppName/
c:\Users\user\Appdata\RoamingAppName
and I confirm this with print statements as the path is constructed and used.
All of this works well enough under Mint 21.2, but when I execute the code under Win 11, either from the command line using python .\appName.py in the working directory or from within VSCode,
the directory in which the INI file ends up in is:
C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\Roaming\appName\
While for the time being, I can work around this since I know where to look for my files, It will be very frustrating in the long run.
As it is, I cannot blame wxPython for this issue, but this forum seems to be the most likely place to get help.
FWIW, under Mint, I am running in a virtual environment, but not under Windows, as that did not seem necessary.