From the course: Python Projects

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

Save configuration settings

Save configuration settings - Python Tutorial

From the course: Python Projects

Save configuration settings

- [Instructor] I want to show you how I implemented my first backlog feature to save and restore configuration settings when I exit and restart my application as an example of how I integrated new code into my existing program. Fortunately, all of the configuration settings I needed to save, existed as part of the GUI, so I only needed to add code within my GUI module. In order to save information between program runs, I'll need to save it to some sort of file. All of my GUI information can be represented as text data, so I decided to use JSON as my file format, and you can see that I imported the JSON module up at line five. Scrolling down, I added two new methods to my GUI class, a save config method at line 259 and a load config method at line 276. Within the save config method, I get the current state from all of my GUI elements, package them into a configuration dictionary and then save that to file using the JSON.dump function on line 271. Notice that this method has an optional…

Contents