Storing your configuration with StandardPaths
You have built your cross platform application, but in order to run your application on multiple platforms, you also need a standard way to access external resources, such as icons and user configuration data. Luckily, wxPython also has a cross platform way to access standard system paths. There are the platform-specific locations where applications store their user configuration data, which can be accessed through the StandardPaths
singleton. In this recipe, we will take a look at how to set up and access application configuration data using StandardPaths
.
How to do it…
Perform the following steps:
First, we will start by defining a class to help manage the configuration of an application:
import os import json import wx class AppConfig(object): _instance = None def __init__(self): super(AppConfig, self).__init__() # create base dir if it doesnt exist if not os.path.exists(self.UserConfigDir): os.mkdir...