Re: Recommendation to deal with NVDA's configurations in add-ons.


DaVid
 

Hi there!.
Again, I added a small but big change to this utility to help dealing
with the add-ons settings.
Now, all the things can be done with a class decorator. But you can
use the older whay if you want.
see the complete information here:
https://github.com/davidacm/NVDADevelopmentUtilities

Let's see how easy is to write a spec now, and help to the ides to
understand the configuration. All things declared in just one place.


# first, import the utility. The decorator and the register config function.
from ._configHelper import configSpec, registerConfig

# now the class definition, with the decorator first.
# this decorator will replace the attributes with a descriptor to
manage accessing and updating values.
@configSpec
class AppConfig:
# the config path. Important to call it __path__ = ...
__path__ = 'beepKeyboard'
# now the definition of the settings. in form of name = 'desc'
beepUpperWithCapsLock = 'boolean(default=True)'
beepCharacterWithShift = 'boolean(default=False)'
beepToggleKeyChanges = 'boolean(default=False)'
announceToggleStatus = 'boolean(default=True)'
disableBeepingOnPasswordFields = 'boolean(default=True)'
ignoredCharactersForShift = "string(default='\\x1b\\t\\b\\r ')"
beepForCharacters = "string(default='')"
shiftedCharactersTone = 'int_list(default=list(6000,10,25))'
customCharactersTone = 'int_list(default=list(6000,10,25))'
capsLockUpperTone = 'int_list(default=list(3000,40,50))'
toggleOffTone = 'int_list(default=list(500,40,50))'
toggleOnTone = 'int_list(default=list(2000, 40, 50))'
AF = registerConfig(AppConfig)

# accessing an option:
print("this should print False", AF.disableBeepingOnPasswordFields)
# changing the value:
AF.disableBeepingOnPasswordFields = True
# let's see the new value.
print("this should print True", AF.disableBeepingOnPasswordFields)

It can't be easier! I wish to use python typings to make the config
description, and that would help to reduce typing errors. But for now,
is enough for me. Although I think that this idea is perfectly
possible.


Saludos,
David CM.



2022-07-30 5:26 GMT-06:00, DaVid via groups.io <dhf360@...>:

Join nvda-addons@nvda-addons.groups.io to automatically receive all group messages.