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


DaVid
 

Hi again. I decided to do all the stuff in a configHelper, so, now is
easier to define a conspec. and the options can be recognized by the
ides without issues. I need to do more tests, but I like this way of
declaring configurations specs for add-ons.

Now, to declare a spec you can do the following, if you use this util.

from ._configHelper import *
class AppConfig(BaseConfig):
def __init__(self):
super().__init__('speechHistoryExplorer')

# declaration of the options for the config.
maxHistoryLength = OptConfig('integer(default=500)')
trimWhitespaceFromStart = OptConfig('boolean(default=false)')
trimWhitespaceFromEnd = OptConfig('boolean(default=true)')
beepWhenPerformingActions = OptConfig('boolean(default=true)')
beepPanning = OptConfig('boolean(default=true)')
AF = registerConfig(AppConfig)

And to acces or set a configuration:

AF.beepPanning
AF.beepPanning = True

It can be improved a lot, but is enough for me.

the config helper can be found here:
https://raw.githubusercontent.com/davidacm/SpeechHistoryExplorer/SPE/addon/globalPlugins/speechHistoryExplorer/_configHelper.py

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