Last October a new set of calls was added to PySimpleGUI.... the UserSettings APIs.
https://pysimplegui.readthedocs.io/en/latest/#user-settings-api
As more information is saved by PySimpleGUI programs, including the global settings used by PySimpleGUI itself, it was clear that users, including the PySimpleGUI project, could benefit from a simplified interface to JSON files.
You'll find it's used in a number of demo programs now and I use it a lot in my own programs.
With these APIs, you don't need to worry about doing loads and saves of the JSON file. The API calls will do that for you.
This simplified access enables you to load defaults straight into your layout.
For example, I used the class-based interface to them to load a list of white-listed users using these 2 lines of code.
First is simply creating the UserSetting object.
config_settings = sg.UserSettings(LOCAL_CONFIG)
Then in my layout, I have this Multiline element:
[sg.Multiline( '\n'.join(config_settings.get('whitelist', [''])), s=(80,10), k='-WHITELIST-')]
It created a Multiline element like this this in my window:
If you want to save something into one of these settings files, it's this line of code:
config_settings['whitelist'] = values['-WHITELIST-'].rstrip().split('\n')
I get the value from the Multiline element, strip to remove whitespace, then split using '\n' to get a list of users.
Because I'm using the class-interface to the UserSettings in this example, I can change and save an item in the JSON as if the object is a dictionary.
I dunno... maybe it'll save you a bit of coding.
For simple programs where there's only 1 settings file that I'm using, I use the function-interface rather than the class-interface.
Nice job on this repo! Keep on building stuff!!