Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to store and retrieve app settings #82

Open
alexdewar opened this issue Dec 5, 2022 · 4 comments
Open

Add ability to store and retrieve app settings #82

alexdewar opened this issue Dec 5, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@alexdewar
Copy link
Contributor

I wrote something bespoke for iPANACEA, but I feel like it's a general enough solution that it could be moved to guikit in some form or other. The general idea is that you have a global settings object (rather like the global logger object we have now) which you can use to get and set different values. When a value is changed, this is signalled using pubsub so e.g. the GUI can update.

I'm not sure whether the best way to do this is as another extension or in some other way.

@alexdewar alexdewar added the enhancement New feature or request label Dec 5, 2022
@dalonsoa
Copy link
Collaborator

dalonsoa commented Dec 8, 2022

I think this should be part of the core guikit functionality and not an extension. It is a very fundamental thing to be able to add new settings.

This is what we did in dtcmr, letting each extension to add their own settings, like in here (the presenter is imported in __init__.py of the extension, so these settings become available).

I think this approach - or a similar one - could be integrated into guikit.

@alexdewar
Copy link
Contributor Author

Interesting. It seems similar to what I did for iPANACEA: https://github.com/ImperialCollegeLondon/iPANACEA/blob/08df0d928dabfb66de4b168778c5927a11b137b8/ipanacea/settings_file.py

As far as I can tell, you're not saving the settings to file anywhere in DT-CMR though, right? Perhaps we'd need a distinction between persistent and non-persistent settings?

The fact that we've independently hit on something similar does suggest that it should be abstracted out into guikit. I think what I did for iPANACEA (or something similar) is probably suitable, though maybe I'd go for toml rather than yaml as a file format.

@dalonsoa
Copy link
Collaborator

dalonsoa commented Dec 8, 2022

Rather than a singleton class, I used global dictionaries and functions in DTCMR, but otherwise it is the same idea, yes. What option is best, to be honest I don't know.

Shall we bring other members of the team into the discussion to gather their opinion?

@AdrianDAlessandro @dandavies99 @TinyMarsh @cc-a @CWestICL @dc2917

@alexdewar
Copy link
Contributor Author

I think it's convenient to have a custom getter/setter for handling the settings (e.g. so that you can write the settings to disk when they're changed) and I did do it with a singleton class, but you could totally make it more dict-like if you wanted, by inheriting from UserDict.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants