I have created a small Python GUI for controlling the I2C pins of my MCU board. Now I want to try and save the settings of this GUI into a config file, so that the file settings could be changed based on the MCU being used.
I have no idea how to create a config file. I tried to looking into links on how to create and use a config file (e.g. ConfigParse
), but could not understand much. Can somebody please help me out?
I am using Python 3.4 on Windows 7.
You're on the right tracks with using ConfigParser! Linked are the docs that should be very useful when programming using it.
For you, the most useful think will likely be the examples, which can be found here. A simple program to write a config file can be found below
This program will write some information to the file "example.ini". A program to read this:
Then you can simply use it like you would any other dictionary. Accessing values like:
Credit given to python docs.