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 CECGen: def __init__(self, parent, label, init, name, gen, size, colour, tooltip): self.name = name self.gen = gen self.size = size self.oldLength = -1 self.label = Label(parent, label, colour=colour[0]) self.entry = ListEntry(parent, init, colour=colour[1]) if tooltip != '': self.toggle.SetToolTip(CECTooltip(tooltip)) def getRate(self): return 'table' def getName(self): return self.name def getValue(self): return self.entry.getValue() def setValue(self, value, dump=None): self.entry.setValue(value) def getCeciliaText(self): value = self.getValue() value = value.split(',') value = [val.strip() for val in value] value = [val for val in value if val != ''] length = len(value) if self.gen == -2 and self.oldLength != length: for i in range(24): self.size = int(math.pow(2,(i+1))) if self.size > length: break self.oldLength = length args = ', '.join(value) orchtext = 'gi%s ftgen 0, 0, %d, %d, %s\n' % (self.name, self.size, self.gen, args) orchtext += 'gi%slen = %d\n' % (self.name, length) return orchtext
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)