Hi,
I'm trying to get my file history to read/write to a wx config file. I currently using the external python module ConfigObj for my configuration files, but it seems wx has a way for the file history to work with wx.config automatically, so that seems the easiest route to take.
self.filehistory = wx.FileHistory(5)
self.config = wx.Config("Whyteboard")
self.config.SetPath(os.path.join(get_home_directory, "directories.list"))
self.filehistory.Load(self.config)
At this point, no config file exists, but I thought wx would auto-create it or something, can't find too many examples of config
And in my file open handler:
def handle_files(self, path):
self.directory = os.path.dirname(path)
self.filehistory.AddFileToHistory(path)
self.filehistory.Save(self.config)
if path.endswith(".wtbd"):
self.util.load_wtbd(path)
else:
self.util.temp_file = path
self.util.load_file()
And my "utility" function:
def get_home_dir(extra_path=None):
std_paths = wx.StandardPaths.Get()
path = wx.StandardPaths.GetUserLocalDataDir(std_paths)
if extra_path:
path = os.path.join(path, extra_path, "") # "" forces slash at end
if not os.path.isdir(path):
os.makedirs(path)
return path
I was hoping that the x many "last remembered" files in self.filehistory's constructor would be auto-written into the config file every time I loaded a file, but it's not the case. I'm not sure if I have to explicitly write the changes, or even explicitly create the config file, as it doesn't get created.
regards,
···
--
Steven Sproat, BSc
http://www.basicrpg.com/