Question

I need to store a user specific list of recently opened files (and some more) for an application I develop. I’ve come across several threads but most of them are about four years old. I would like to know if there are smarter and modern ways for that other than what I have mentioned here.

  1. I can save setting to an XML file and for later reload. In that case, which folder should I use to save the xml, if I’m working in windows (where should I create a user specific folder in windows to save)?
  2. I can integrate recently used files to the wxpython persistence manager and let that work for me.

Please advice.

I use wxpython 3 with python 2.7.

Was it helpful?

Solution

I would recommend using wx.StandardPaths to determine where to store files of this sort in a cross-platform manner. There is a good demo in the wxPython demo. Or you can read about its API in the documentation.

There are lots of different ways to persist your information. You can use XML as you mentioned or any of the following:

  • Python's pickle module would be really easy to use
  • JSON
  • sqlite

Or you could use wxPython's persistence manager as you mentioned. It really depends on which one you find easiest to use and how easy you want the list to be read and modified outside your UI.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top