I wrote json configuration file:
{
"file": {"file_name": "file.xls"},
"names1":
{"Joe Allen": "JOE",
"Leo Messi": "MESSI"}
}
It is formatted and readable. I use function to change file_name:
def plik(self, evt):
wildcard = "MS excell (*.xls)|*.xls"
dialog = wx.FileDialog(self, "Choose a file", os.getcwd(), "", wildcard, wx.OPEN)
if dialog.ShowModal() == wx.ID_OK:
config['file'] = {'file_name': dialog.GetFilename()}
with open('config.json', 'w') as f:
json.dump(config, f)
self.Destroy()
frame = Program()
frame.Show()
After change text in json file looks like:
{"file": {"file_name": "file.xls"},"names1":{"Joe Allen": "JOE","Leo Messi": "MESSI"}}
What should I do to keep formating.