Storing preferences correctly

Each platform defines a proper location for storing user configuration files as follows:

  • Linux and other X11 systems store configuration files in a location defined in the $XDG_CONFIG_HOME environment variable, which defaults to ~/.config if it's not defined.
  • macOS user config files are stored in ~/Library/Application Support/.
  • Windows user config files are stored in %USERPROFILE%\AppData\Local. Though if your environment uses Active Directory (AD) with roaming profiles, you might prefer to use %HOME%\AppData\Roaming instead.

To realize this in our application, we'll edit our Application object to pass the correct path into SettingsModel. Remember that our SettingsModel constructor takes a path keyword argument ...

Get Python GUI Programming with Tkinter now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.