class CECPopup: def __init__(self, parent, label, values, init, rate, name, colour, tooltip, output=True): self.type = "popup" self.name = name self.output = output self.rate = rate self.label = Label(parent, label, colour=colour[0]) self.popup = CustomMenu(parent, values, init, size=(100,20), outFunction=self.onPopup, colour=colour[1]) self.label.SetToolTip(CECTooltip(TT_POPUP)) if tooltip != '': self.popup.SetToolTip(CECTooltip(tooltip)) def getName(self): return self.name def getValue(self): return self.popup.getIndex() def getFullValue(self): return self.popup.getIndex(), self.popup.getLabel() def getLabel(self): return self.popup.getLabel() def setValue(self, value, out=False): self.popup.setByIndex(value, out) def onPopup(self, value, label): if CeciliaLib.getVar("currentModule") != None and self.output and self.rate == "k": getattr(CeciliaLib.getVar("currentModule"), self.name)(value, label)
class CECToggle: def __init__(self, parent, label, init, rate, name, colour, tooltip, stack=False, output=True): self.type = "toggle" self.name = name self.rate = rate self.output = output if label != '': if stack: self.label = Label(parent, label, colour=colour[0], size=(210, 20)) else: self.label = Label(parent, label, colour=colour[0], size=(100, 20)) self.label.SetToolTip(CECTooltip(TT_TOGGLE)) self.toggle = Toggle(parent, init, outFunction=self.onToggle, colour=colour[1]) if tooltip != '': self.toggle.SetToolTip(CECTooltip(tooltip)) def getName(self): return self.name def getValue(self): return self.toggle.getValue() def setValue(self, state, dump=None): self.toggle.setValue(state) def onToggle(self, value): if CeciliaLib.getVar("currentModule") != None and self.output: getattr(CeciliaLib.getVar("currentModule"), self.name)(value)
class CECGen: def __init__(self, parent, label, init, rate, name, popup, colour, tooltip): self.type = "gen" self.name = name self.rate = rate self.popup = popup self.oldLength = -1 self.label = Label(parent, label, colour=colour[0]) self.entry = ListEntry(parent, ", ".join([str(x) for x in init]), colour=colour[1], outFunction=self.onEntry) self.label.SetToolTip(CECTooltip(TT_GEN)) if tooltip != '': self.label.SetToolTip(CECTooltip(tooltip)) def getName(self): return self.name def convertToList(self, value): if "," in value: value = value.split(',') else: value = value.split(" ") value = [eval(val) for val in value if val.strip() != ""] return value def getValue(self): return self.convertToList(self.entry.getValue()) def setValue(self, value, dump=None): self.entry.setValue(value) def onEntry(self, value): if type(value) != ListType: value = self.convertToList(value) if CeciliaLib.getVar("currentModule") != None and self.rate == "k": getattr(CeciliaLib.getVar("currentModule"), self.name)(value) if self.popup != None: self.popup[0].setValue(self.popup[1], True)
class CECButton: def __init__(self, parent, label, name, colour, tooltip): self.type = "button" self.name = name self.label = Label(parent, label, colour=colour[0]) self.button = Button(parent, outFunction=self.onButton, colour=(colour[1],colour[0])) self.label.SetToolTip(CECTooltip(TT_BUTTON)) if tooltip != '': self.button.SetToolTip(CECTooltip(tooltip)) def getValue(self): return 0 def getName(self): return self.name def onButton(self, value): if CeciliaLib.getVar("currentModule") != None: getattr(CeciliaLib.getVar("currentModule"), self.name)(value)