Question about config in addons


Javi Domínguez
 

Hello.


I don't understand what happens with configuration values ​​that unexpectedly they change their type. I'm goin to describing the problem:


I have this definition:


confspec = {
    "folder":"string(default=/)",
    "format":"string(default=BMP)",
    "action":"integer(default=2)",
    "step":"integer(default=5)",
    "scale":"boolean(default=false)"
}

Note that scale is boolean.


I then assign to profile[0] because I want my addon to be independent of the active profile. I'm not sure if this is the right way but it usually works for me:


config.conf.profiles[0]["screenshots"]["scale"] = config.conf["screenshots"]["scale"]

The problem comes when I open the settings panel


    self.checkboxEnlargement.SetValue(config.conf.profiles[0]["screenshots"]["scale"])
TypeError: CheckBox.SetValue(): argument 1 has unexpected type 'str'


I jump this error to be able to continue the execution and I get to:


config.conf.profiles[0]["screenshots"]["scale"] = self.checkboxEnlargement.GetValue()

Here the type is boolean, correct, And so it continues for the rest of the session, until I restart NVDA. When the GlobalPlugin is reloaded, in the first line of __init__ I check the type and it is STR.


I can patch it by adding a few lines and it will work but I'd rather understand what's going on. Does anyone have any ideas?


Full code is here: https://github.com/javidominguez/screenshots/tree/dev


Thanks


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