Override indiPrefs to display in Configure menu

Posted on
Fri Feb 17, 2017 11:05 am
KostasV offline
Posts: 39
Joined: Nov 16, 2014
Location: London, UK

Override indiPrefs to display in Configure menu

Hello everyone,

I have 4 textfields in the plugin menu and from everything works fine, the values are saved as expected in the IndiPrfs XML.

For a number of reasons I want to 'override' this and for one of the textfields to display something else (well the original value minus something), is that possible?

I haven't seen any method that occurs before the ConfigUi is shown, I know about the validate and the closedConfig but is there one for before showing it?

Thanks!

Kostas

Posted on
Fri Feb 17, 2017 12:01 pm
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Override indiPrefs to display in Configure menu

A couple of approaches: first, if you want the user to enter a value thats always transformed in some way before you use it (but you want the user to enter pre transformation) then just add a key to the valuesDict that you populate with the calculated value in the validation call.

Code: Select all
valuesDict["calculatedValue"] = valuesDict["rawValue"] - 2 # or whatever


That way the user sees what they're expecting but you always get the value you want in the calculated field (self.pluginProps["calculatedValue"]).

If you really must modify it before the dialog opens, you can implement the following method which is called to get the values before the ConfigUI is drawn to get the values::

Code: Select all
def getPrefsConfigUiValues(self):
    valuesDict, errorMsgDict = super(Plugin, self).getPrefsConfigUiValues()
    # modify valuesDict["yourkey"] as necessary
    return (valuesDict, errorMsgDict)


You call the base class's implementation to get the values (it also returns an error message dictionary), then modify the value as necessary before returning both dicts as a tuple.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri Feb 17, 2017 12:42 pm
KostasV offline
Posts: 39
Joined: Nov 16, 2014
Location: London, UK

Re: Override indiPrefs to display in Configure menu

Many thanks Jay! You are a star!

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests