Help with enabledBindingId not functioning

Posted on
Thu May 10, 2018 6:56 am
vtmikel offline
Posts: 628
Joined: Aug 31, 2012
Location: Boston, MA

Help with enabledBindingId not functioning

I'm having trouble with this attached form.

The "Applies to all devices" is supposed to disable the "Devices this filter applies to" when enabled. I had this working by adding the properties of the listbox:

enabledBindingId="filterAllDevices" enabledBindingNegate="true"

This worked fine. However, as I built the form further, I needed to have the checkbox and listbox visibility bound to another control, so I added to both controls:

visibleBindingValue="edit,add" enabledBindingId="editMode"

This broke the enabled binding for the "devices this filter applies to" listbox. The visibility binding works fine for both. The enabled binding works when the visible binding is removed, and immediately stops working when I add it back in.
Attachments
Screen Shot 2018-05-09 at 4.00.09 PM.png
Screen Shot 2018-05-09 at 4.00.09 PM.png (484.16 KiB) Viewed 1202 times

Posted on
Thu May 10, 2018 9:05 am
jay (support) offline
Site Admin
User avatar
Posts: 18200
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Help with enabledBindingId not functioning

Combining visible and enabled bindings is probably something best avoided (there are definitely limitations). You may be able to use the dynamicReload flag with a common method call such that whenever a button or menu item is changed the method is called with the new values - that would enable you to set flags as necessary (use hidden checkboxes for instance to control behavior). Without seeing a complete ConfigUI (preferably a short example of what you're trying to do) it's hard to know for sure.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Thu May 10, 2018 9:26 am
vtmikel offline
Posts: 628
Joined: Aug 31, 2012
Location: Boston, MA

Re: Help with enabledBindingId not functioning

If there's a way to programmatically control the hidden property, that would probably solve my issue. Is there an example of this you can point me to?

Posted on
Thu May 10, 2018 10:26 am
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: Help with enabledBindingId not functioning

Yes
Set the hiddenid to a check box
Then in program set that checkbox to true/false

I have in one of my plugins >>10 of this to switch certain fields visible / hidden.

then you need to have a central method that is called by the buttons the users click
That method then will set visible on/off for all



Sent from my iPhone using Tapatalk

Posted on
Thu May 10, 2018 12:14 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: Help with enabledBindingId not functioning

here the hidden indicators in eg devcie.xml
Code: Select all
<Field id="ExpertsAndPlots"        type="checkbox" defaultValue="false" hidden="yes"> </Field>
<Field id="ExpertsAndLines"        type="checkbox" defaultValue="false" hidden="yes"> </Field>
<Field id="selectLinesOK"          type="checkbox" defaultValue="false" hidden="yes"> </Field>
<Field id="DefineLinesANotSelect"  type="checkbox" defaultValue="true"  hidden="yes"> </Field>
<Field id="DefineLinesASelected"   type="checkbox" defaultValue="true"  hidden="yes"> </Field>
<Field id="DefineLinesBNotSelect"  type="checkbox" defaultValue="true"  hidden="yes"> </Field>
<Field id="DefineLinesBSelected"   type="checkbox" defaultValue="true"  hidden="yes"> </Field>
<Field id="showFunc"               type="checkbox" defaultValue="true"  hidden="yes"> </Field>
<Field id="fontsGNUONOFF"          type="checkbox" defaultValue="false" hidden="yes"> </Field>
<Field id="fontsMATONOFF"          type="checkbox" defaultValue="false" hidden="yes"> </Field>
<Field id="TimeseriesAndPlots"     type="checkbox" defaultValue="true"  hidden="yes"> </Field>
<Field id="showBins"               type="checkbox" defaultValue="true"  hidden="yes"> </Field>
<Field id="showBinsS"              type="checkbox" defaultValue="true"  hidden="yes"> </Field>
<Field id="showXscale"             type="checkbox" defaultValue="true"  hidden="yes"> </Field>
<Field id="showY2scale"            type="checkbox" defaultValue="false" hidden="yes"> </Field>
<Field id="showRGBBackground"      type="checkbox" defaultValue="true"  hidden="yes"> </Field>
<Field id="showRGBText"            type="checkbox" defaultValue="true"  hidden="yes"> </Field>
<Field id="polarLineText"          type="checkbox" defaultValue="false" hidden="yes"> </Field>
<Field id="polarPlotText"          type="checkbox" defaultValue="false" hidden="yes"> </Field>
<Field id="amPm"                   type="checkbox" defaultValue="false" hidden="yes"> </Field>
<Field id="leftRight"              type="checkbox" defaultValue="false" hidden="yes"> </Field>
<Field id="showExtraText"          type="checkbox" defaultValue="false" hidden="yes"> </Field>
<Field id="showNotScatter"         type="checkbox" defaultValue="false" hidden="yes"> </Field>
<Field id="showNotScatterS"        type="checkbox" defaultValue="false" hidden="yes"> </Field>
<Field id="showNotScatterC"        type="checkbox" defaultValue="false" hidden="yes"> </Field>
<Field id="showSmooth"             type="checkbox" defaultValue="false" hidden="yes"> </Field>
<Field id="showLineShift"          type="checkbox" defaultValue="false" hidden="yes"> </Field>


used like this in eg devcie.xml:
Code: Select all
<Field enabledBindingId="selectLinesOK" visibleBindingId="showLineShift" visibleBindingValue="true" id="lineShift" type="menu" defaultValue='0' tooltip="1 would show yesterdays data today,   365 would show last years data today">....



then set like this:
Code: Select all
    def setViewOnOff(self, valuesDict):


        try:
            if valuesDict["DefinePlots"]:
                if valuesDict["PlotType"] =="dataFromTimeSeries":
                    valuesDict["TimeseriesAndPlots"] = True
                else:
                    valuesDict["TimeseriesAndPlots"] = False

                if valuesDict["XYvPolar"] =="xy" and valuesDict["ExpertsP"] == True and valuesDict["PlotType"] == "dataFromTimeSeries":
                    valuesDict["showBinsS"] = True
                    valuesDict["amPm"] = True
                else:
                    valuesDict["showBinsS"] = False
                    valuesDict["amPm"] = False
               
                if valuesDict["PlotType"] =="dataFromTimeSeries" and valuesDict["XYvPolar"] =="polar":
                    valuesDict["polarPlotText"] = True
                    valuesDict["showBinsS"] = False
               
                if valuesDict["PlotType"] !="dataFromTimeSeries" or valuesDict["XYvPolar"] =="polar":
                    valuesDict["showXscale"] = True
                    valuesDict["showBinsS"] = False
                else:
                    valuesDict["showXscale"] = False

                if valuesDict["XYvPolar"] =="polar":
                    valuesDict["showY2scale"] = False
                    valuesDict["polarPlotText"] = True
                else:
                    valuesDict["showY2scale"] = True
                    valuesDict["polarPlotText"] = False

                if valuesDict["ExpertsP"]:
                    valuesDict["showRGBBackground"] = True
                    valuesDict["showRGBText"] = True
                    valuesDict["ExpertsAndPlots"] = True
                    valuesDict["showBins"] = True
                    valuesDict["showExtraText"] =True

                    if  self.gnuORmat == "gnu":
                        valuesDict["fontsGNUONOFF"] = True
                        valuesDict["fontsMATONOFF"] = False
                    else:
                        valuesDict["fontsMATONOFF"] = True
                        valuesDict["fontsGNUONOFF"] = False
                else:
                    valuesDict["fontsGNUONOFF"] = False
                    valuesDict["fontsMATONOFF"] = False
                    valuesDict["ExpertsAndPlots"] = False
                    valuesDict["showBins"] = False
       
                if len(valuesDict["ExtraText"]) >0:
                    valuesDict["showExtraText"] =True
            else:
                valuesDict["TimeseriesAndPlots"] = True
                valuesDict["fontsGNUONOFF"] = False
                valuesDict["fontsMATONOFF"] = False
                valuesDict["ExpertsAndPlots"] = False
                valuesDict["showBins"] = False
                valuesDict["showBinsS"] = False
                valuesDict["showRGBBackground"] = False
                valuesDict["showRGBText"] = False
                valuesDict["showXscale"] = False
                valuesDict["showY2scale"] = False
                valuesDict["polarPlotText"] = False
                valuesDict["amPm"] = False
                valuesDict["showExtraText"] =False
                valuesDict["showNotScatter"] =False
                valuesDict["showNotScatterS"] =False
                valuesDict["showNotScatterC"] =False
                valuesDict["showLineShift"] =False


            if valuesDict["DefineLines"]:
                if  valuesDict["ExpertsP"]:
#               valuesDict["showRGBLine"] = True
                    if valuesDict["XYvPolar"] =="xy":
                        valuesDict["showFunc"] = True
                    else:
                        valuesDict["showFunc"] = False
                    if valuesDict["lineFunc"] =="E" or valuesDict["showFunc"] =="S" or valuesDict["showFunc"] =="C":
                        valuesDict["showFunc"] = True
                   
                    valuesDict["ExpertsAndLines"] = True
                    if  valuesDict["lineFunc"] =="E" or valuesDict["lineFunc"] =="S":
                        valuesDict["showSmooth"] = False
                        valuesDict["showNotScatter"] = False
                        valuesDict["showNotScatterS"] = True
                    elif valuesDict["lineFunc"] =="C" :
                        valuesDict["showSmooth"] = False
                        valuesDict["showNotScatter"] = False
                        valuesDict["showNotScatterC"] = True
                    else:
                        valuesDict["showSmooth"] = True
                        valuesDict["showNotScatter"] = True
                        valuesDict["showNotScatterS"] = True
                        valuesDict["showNotScatterC"] = True

                    valuesDict["showLineShift"] =True

                    if "StraightLine" in  valuesDict and unicode(valuesDict["StraightLine"]).upper()=="TRUE" or  valuesDict["selectedLineSourceATEXT"].find("-event") >-1:
                        #self.ML.myLog("Plotting",unicode(valuesDict))
                        if valuesDict["StraightLine"] :
                            valuesDict["showFunc"] = False
                            valuesDict["showSmooth"] = False
                            valuesDict["showLineShift"] =False
                   
                    if self.showAB == "SAB":
                        valuesDict["DefineLinesASelected"] =True
                        valuesDict["DefineLinesANotSelect"] =False
                        valuesDict["DefineLinesBSelected"] =True
                        valuesDict["DefineLinesBNotSelect"] =False
                    if self.showAB == "SA":
                        valuesDict["DefineLinesASelected"] =True
                        valuesDict["DefineLinesANotSelect"] =False
                        valuesDict["DefineLinesBSelected"] =False
                        valuesDict["DefineLinesBNotSelect"] =False
                    if self.showAB == "NSAB":
                        valuesDict["DefineLinesASelected"] =False
                        valuesDict["DefineLinesANotSelect"] =True
                        valuesDict["DefineLinesBSelected"] =False
                        valuesDict["DefineLinesBNotSelect"] =True
                    if self.showAB == "NSA":
                        valuesDict["DefineLinesASelected"] =False
                        valuesDict["DefineLinesANotSelect"] =True
                        valuesDict["DefineLinesBSelected"] =False
                        valuesDict["DefineLinesBNotSelect"] =False


                else:
                    valuesDict["showSmooth"] = False
                    valuesDict["ExpertsAndLines"] = False
                    valuesDict["DefineLinesBNotSelect"] = False
                    valuesDict["DefineLinesBSelected"] = False
                    valuesDict["showNotScatter"] = True
                    valuesDict["showNotScatterC"] = True
                    valuesDict["showNotScatterS"] = True
                    if self.showAB == "SAB":
                        valuesDict["DefineLinesASelected"] =True
                        valuesDict["DefineLinesANotSelect"] =False
                    if self.showAB == "SA":
                        valuesDict["DefineLinesASelected"] =True
                        valuesDict["DefineLinesANotSelect"] =False
                    if self.showAB == "NSAB":
                        valuesDict["DefineLinesASelected"] =True
                        valuesDict["DefineLinesANotSelect"] =True
                    if self.showAB == "NSA":
                        valuesDict["DefineLinesASelected"] =False
                        valuesDict["DefineLinesANotSelect"] =True
                    valuesDict["DefineLinesBSelected"] =False
                    valuesDict["DefineLinesBNotSelect"] =False
                    if str(valuesDict["lineFunc"]) =="E" or str(valuesDict["lineFunc"]) =="S" or str(valuesDict["lineFunc"]) =="C":
                        valuesDict["showFunc"] = True
                        if self.showAB.find("N")>-1:
                            valuesDict["DefineLinesBSelected"] =False
                            valuesDict["DefineLinesBNotSelect"] =True
                        else:
                            valuesDict["DefineLinesBSelected"] =True
                            valuesDict["DefineLinesBNotSelect"] =False

                    else:
                        valuesDict["showFunc"] = False

                   
                if valuesDict["XYvPolar"] =="xy":
                    valuesDict["leftRight"] = True
                else:
                    valuesDict["polarLineText"] = True
                    valuesDict["showNotScatter"] = True
                    valuesDict["showNotScatterS"] = True
                    valuesDict["showNotScatterC"] = True
                    valuesDict["textPolarL1"] ="LineA for radius and LineB for angle"
                    valuesDict["showFunc"] = False
                    valuesDict["leftRight"] = False
                    valuesDict["showLineShift"] =False
                    if self.showAB == "SAB":
                        valuesDict["DefineLinesBSelected"] =True
                        valuesDict["DefineLinesBNotSelect"] =False
                    if self.showAB == "NSAB":
                        valuesDict["DefineLinesBSelected"] =False
                        valuesDict["DefineLinesBNotSelect"] =True




            else:
                valuesDict["ExpertsAndLines"] = False
                valuesDict["DefineLinesANotSelect"] = False
                valuesDict["DefineLinesASelected"] = False
                valuesDict["DefineLinesBNotSelect"] = False
                valuesDict["DefineLinesBSelected"] = False
                valuesDict["showRGBLine"] = False
                valuesDict["showFunc"] = False
                valuesDict["leftRight"] = False
                valuesDict["showNotScatter"] = False
                valuesDict["showNotScatterS"] = False
                valuesDict["showLineShift"] =False
                valuesDict["showNotScatterC"] = False
            return valuesDict
        except  Exception, e:
            self.ML.myLog("all","Line '%s' has error='%s'" % (sys.exc_traceback.tb_lineno, e))
#         self.ML.myLog("all",unicode(valuesDict))

        return valuesDict



called by
Code: Select all
   
    def ExpertOnOffPlotCALLBACK(self, valuesDict=None, typeId="", targetId=0):
        valuesDict = self.setViewOnOff(valuesDict)
        return valuesDict
or
    ########################################
    def pickExistingOrNewLineCALLBACK(self,  valuesDict=None, typeId="", targetId=0):         # store user input and set other parameters used later
        self.CurrentLineNo   = "0"
        self.addLine      = False
        nPlot            = str(indigo.devices[targetId].id)
....
                theDefaultColNumber =int(self.PLOT[nPlot]["lines"][self.CurrentLineNo]["lineToColumnIndexB"])               # get the last entry
                if theDefaultColNumber >0:
                    self.showAB=     "SAB"
                    if self.currentPlotType =="dataFromTimeSeries":
                        valuesDict["selectedLineSourceBTEXT"]   = self.listOfSelectedDataColumnsAndDevPropName[theDefaultColNumber][1]
                        valuesDict["selectedLineSourceB"]       = self.listOfSelectedDataColumnsAndDevPropName[theDefaultColNumber][0]
....
        valuesDict =self.setViewOnOff(valuesDict)

...        return valuesDict

probably a bit more complex than you need, but the principle should be clear


Karl

Posted on
Wed May 16, 2018 6:59 am
vtmikel offline
Posts: 628
Joined: Aug 31, 2012
Location: Boston, MA

Re: Help with enabledBindingId not functioning

Thanks for the suggestions. I was able to get something configured to work.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests

cron