onyxcode / hazy

A simple weather GUI program made in Python.
GNU General Public License v3.0
11 stars 0 forks source link

[Suggestion] Settings screen using User Settings API #4

Open PySimpleGUI opened 3 years ago

PySimpleGUI commented 3 years ago

Describe the bug Consider adding a "setup" window and using the PySimpleGUI User Settings API

Screenshots

Here's a screenshot of the setup window for a demo program that uses a weather API Key.

image

Additional context

You'll find the details here of the API calls https://pysimplegui.readthedocs.io/en/latest/call%20reference/#user-settings

Demos can be found in the PySimpleGUI demo programs folder

http://Demos.PySimpleGUI.org

Summary:

The User Settings are a way to interface with JSON files using what appears to be Python dictionaries. They act like persistent dictionaries. There is no need to "save" to a file. If you change a setting, it is automatically saved to the file for you.

onyxcode commented 3 years ago

Thanks for the suggestion! I will look into this in a few hours!

PySimpleGUI commented 3 years ago

The weather widget was updated recently with changes that include using the User Settings API.

There is still a call to json in the code, but it's for an entirely different reason. It's used to read the closest zip code to your location, not for stoping the API key, etc.

There are a bunch of demo programs that use it now. There is a class-based version and a functions only one. The class-based is the easiest. Demo_User_Settings_Class.py is a simple demo.

Here's the most basic of examples:

settings = sg.UserSettings()

settings['my setting'] = 'Some Value'
print(settings['my setting'])

Enjoy!

PySimpleGUI commented 3 years ago

Maybe mention your GUI was made with PySimpleGUI in your readme so others know what you used? Listing packages used in readme's gives visitors a way to see the different technologies used without having to dig into the code.

onyxcode commented 3 years ago

Maybe mention your GUI was made with PySimpleGUI in your readme so others know what you used? Listing packages used in readme's gives visitors a way to see the different technologies used without having to dig into the code.

Funny you say that, I thought I had. Thanks for letting me know :)

onyxcode commented 3 years ago

@PySimpleGUI I will be adding the Settings window soon!