Friday, April 19, 2024
 Popular · Latest · Hot · Upcoming
9
rated 0 times [  9] [ 0]  / answers: 1 / hits: 5036  / 2 Years ago, sat, june 25, 2022, 11:38:59

If I want my application to store a few settings, that persist when an application closes, then where should I store them?



I'm not talking anything complicated: two booleans and a string (although in the future I might want to store more complex settings)



I've heard gconf, dconf, gsettings, etc all mentioned. What is the "preferred" method? Preferably one that's nice and easy in Python.


More From » python

 Answers
3

gconf is deprecated, so for a new project I would not use it. dconf is a backend for storing the settings, as an application developer you should normally not have to bother with it.



What you seem to need is gsettings, a high-level API (API documentation for C) to store/retrieve settings without bothering how/where they are actually stored. gsettings is part of gio, which is one of the core packages of gnome (like glib and gobject). This blog post gives a short introduction how to use it with Python.



If you do not want any dependencies on gio (e.g. you are not developing a GNOME application) and want to store simple config files, I'd suggest to use the $HOME/.config directory (or whatever directory defined by $XDG_CONFIG_DIRS) instead of $HOME/.your_appname, in line with the freedesktop spec.


[#43625] Sunday, June 26, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
bewre

Total Points: 164
Total Questions: 108
Total Answers: 106

Location: Ghana
Member since Sun, Mar 27, 2022
2 Years ago
bewre questions
Sun, May 14, 23, 13:27, 1 Year ago
Mon, Aug 2, 21, 03:57, 3 Years ago
Thu, Aug 26, 21, 18:05, 3 Years ago
Sat, Aug 6, 22, 21:41, 2 Years ago
Sat, Jul 24, 21, 22:52, 3 Years ago
;