raganmd
3/14/2020 - 10:49 PM

MenuFromChildren

'''
used in a custom parameter for a menu. Example syntax would be:
me.mod.datMenuMOD.MenuFromChildren(op('someOp'), parName)

where null_menu is a table with at least two columns:
name
label'''

class MenuFromChildren:

    def __init__(self, path, parName):
        self.myPath = path
        self.parName = parName

    @property		
    def menuNames(self):
        return [eachOp.op('null_final').path for eachOp in self.myPath.findChildren(type=baseCOMP, depth=1)]

    @property
    def menuLabels(self):
        return [getattr(eachOp.par, self.parName) for eachOp in self.myPath.findChildren(type=baseCOMP, depth=1)]