예제 #1
0
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)
예제 #2
0
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)
예제 #3
0
class CECToggle:
    def __init__(self, parent, label, init, name, colour, rate, tooltip):
        self.name = name
        self.label = Label(parent, label, colour=colour[0])
        self.rate = rate
        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 getRate(self):
        return self.rate

    def getValue(self):
        return self.toggle.getValue()
    
    def setValue(self, state, dump=None):
        self.toggle.setValue(state)

    def onToggle(self, value):
        if self.rate == 'k':
            CeciliaLib.getCsound().setChannel("%s_value" % self.name, value)

    def getCeciliaText(self):
        orchtext = ''
        scotext = ''
        if self.rate == 'k':
            orchtext += 'instr Cecilia_%s\n' % self.name
            orchtext += 'gk%s chnget "%s_value"\n' % (self.name, self.name)
            orchtext += 'endin\n\n'
            
            scotext += 'i "Cecilia_%s" 0 %f\n' % (self.name, CeciliaLib.getTotalTime())
        return orchtext, scotext