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

Beautify preferences #201

Open
ianhoffman opened this issue Nov 29, 2020 · 0 comments
Open

Beautify preferences #201

ianhoffman opened this issue Nov 29, 2020 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@ianhoffman
Copy link
Collaborator

ianhoffman commented Nov 29, 2020

To make it simple to add a preference, I created a basic framework where you define preferences a descriptors on the Client class; e.g.,

class Client(...):
    # ...

    my_preference = IntegerPreference(
        display_name=lazy_gettext("My Preference"),
        description=lazy_gettext("..."),
        default=42,
   )

The preference can then be used as follows:

assert client.my_preference == 42, "This should work"
client.set_pref("my_preference", 99)
assert client.my_preference == 99, "This works too"
client.my_preference = 81
assert client.my_preference == 81, "This too!"

This works fairly well, but it results in a UX which isn't quite as fluid as we'd like. For example, IntegerPreference exposes a get_prompt() method which returns a prompt like "Enter an integer between %(min_value)s and %(max_value)s.". In the case of the alert_frequency pref, for example, this result in a prompt like Enter an integer between 0 and 24. Note that we don't mention "hours" anywhere. Context is missing.

So this ticket is really just arguing that there should be a clean way to add more nuance to the prompts generated by these prefs' get_prompt() method. We would like to keep adding a new pref simple while allowing this extra flexibility.

@ianhoffman ianhoffman added enhancement New feature or request good first issue Good for newcomers labels Nov 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant