Ejemplo n.º 1
0
            self.v_pad.show()
        else:
            self.v_pad.hide()

    def v_scroll(self, value):
        sb = self.v_pad
        target_sb = self.scrollarea.verticalScrollBar()
        percent = sb.value() / float(sb.maximum())
        target_sb.setValue(int(percent * target_sb.maximum()))

    def h_scroll(self, value):
        sb = self.h_pad
        target_sb = self.scrollarea.horizontalScrollBar()
        percent = sb.value() / float(sb.maximum())
        target_sb.setValue(int(percent * target_sb.maximum()))


if __name__ == '__main__':
    from pk.widgets.utils import run_widget
    from PyQt4.QtGui import QLabel, QPixmap
    class TestScrollArea(ScrollArea):
        def __init__(self, parent=None):
            ScrollArea.__init__(self, parent)
            widget = QLabel()
            widget.setPixmap(QPixmap(':/static/pkstudio_bg.png'))
            widget.setFixedSize(1000, 1000)
            self.setWidget(widget)

    run_widget(TestScrollArea)

Ejemplo n.º 2
0
            QWidget.__init__(self)
            Layout = QGridLayout(self)

            self.synth = synths.Synth(self)
            self.synth.add_note(time.time() + .5, time.time() + 1.5)
            self.synth.add_note(time.time() + 1, time.time() + 2)
            self.synth.add_note(time.time() + 1.5, time.time() + 2.5)
            synthpart = LoopPart(self.synth, self)
            synthpart.selected = True
            synthpart.songpart = 'drums'
            synthpart.activeLED.show()
            Layout.addWidget(synthpart, 0, 0)
            
            effectpart = EffectPart(None, self)
            Layout.addWidget(effectpart, 0, 1)
            
            self.pattern = engine.Pattern()
            self.pattern.beats = 4
            for i in (0, 64, 128, 196):
                stop = i + random.randint(16, 32)
                pitch = random.randint(32, 96)
                self.pattern.add(engine.Note(i, stop, pitch))
            Layout.addWidget(PatternPart(self.pattern, self), 1, 0)

            self.startTimer(100)

        def timerEvent(self, e):
            self.synth.update()
        
    run_widget(Glob)
Ejemplo n.º 3
0
        
    def midiInput(self, msg):
        channel, value1, value2, timestamp = msg
        if value1 == 7:
            self.volumeSlider.setValue(value2)
            self.emit(SIGNAL('volume(QWidget *, float)'), value2 / 127.0)
        elif value1 == 13:
            self.panKnob.setValue(value2)
        elif value1 == 12:
            self.send1Knob.setValue(value2)
        elif value1 == 10:
            self.send2Knob.setValue(value2)


if __name__ == '__main__':
    from pk.widgets.utils import run_widget
    import synths
    import effects
    import pattern
    import parts
    class TestChannel(Channel):
        def __init__(self):
            Channel.__init__(self)
            self.a = parts.SynthPart(synths.Sine())
            self.a.show()
            self.b = parts.EffectPart(effects.Effect(None))
            self.b.show()
            self.c = parts.PatternPart(pattern.Pattern())
            self.c.show()
    run_widget(TestChannel)
Ejemplo n.º 4
0
        self.setFixedWidth(spec.PART_WIDTH + self.margin * 2)
        self.parts = []

    def add(self, part):
        part.setParent(self)
        part.show()
        self.parts.append(part)
        self._rearrange()

    def _rearrange(self):
        y = 0
        for part in self.parts:
            part.move(self.margin, y)
            y += part.height()
        self.setFixedSize(self.width(), y)


if __name__ == '__main__':
    from pk.widgets.utils import run_widget
    import parts
    import synths
    class TestSelector(Selector):
        def __init__(self):
            Selector.__init__(self)

            for i in range(5):
                self.add(parts.SynthPart(synths.Sine()))
                self.add(parts.SynthPart(synths.Sample()))
    run_widget(TestSelector)

Ejemplo n.º 5
0
    def off(self):
        self._on = False
        self.update()

    def blink(self):
        self.on()
        QTimer.singleShot(300, self.off)

    def flashing(self):
        self.on()
        self._flashing = True
        self.keep_flashing()

    def stop(self):
        self._flashing = False

    def keep_flashing(self):
        if self._flashing:
            self.on()
            QTimer.singleShot(250, self.off)
            QTimer.singleShot(500, self.keep_flashing)


if __name__ == '__main__':
    from pk.widgets.utils import run_widget
    class TestLED(LED):
        def __init__(self):
            LED.__init__(self)
            self.flash()
    run_widget(TestLED)
Ejemplo n.º 6
0
            part.text += '\n(%i beats)' % beats
        synths_.add(part)
    effects.add(parts.EffectPart(scsynth.Effect()))
    effects.add(parts.EffectPart(scsynth.Effect()))

    patterns = os.listdir(spec.PATTERNS)
    patterns.sort(string_cmp)
    for fname in patterns:
        if fname.lower().endswith('.xml'):
            fpath = os.path.join(spec.PATTERNS, fname)
            part = parts.PatternPart(scsynth.read_pattern(fpath))
            patterns_.add(part)


if __name__ == '__main__':
    from PyQt4.QtGui import QColor
    import parts
    from pk.widgets.utils import run_widget
    class FakePlayer:
        def load(self, fpath):
            return 0
    class TestToolBox(ToolBox):
        def __init__(self):
            ToolBox.__init__(self)
            self.setAutoFillBackground(True)
            self.palette().setColor(self.backgroundRole(),
                                    QColor(136, 136, 136))
            load_all(self, FakePlayer())
            self.resize(self.width(), 600)
    run_widget(TestToolBox)
Ejemplo n.º 7
0
    def resizeEvent(self, e):
        if self.x is None:
            self.x = self.width() / 2
        if self.y is None:
            self.y = self.height() / 2
        
    def mouseMoveEvent(self, e):
        self.x = e.x()
        self.y = e.y()
        self.update()
        self.emit(SIGNAL('valueChanged(int, int)'), (self.x, self.y))
        
    def paintEvent(self, e):
        painter = QPainter(self)

        painter.setPen(QColor('black'))
        painter.setBrush(QColor('black'))
        painter.drawRect(0, 0, self.width(), self.height())
        
        painter.setPen(self.line_brush)
        painter.setBrush(self.line_brush.dark(150))
        painter.drawLine(self.x, 0, self.x, self.height())
        painter.drawLine(0, self.y, self.width(), self.y)



if __name__ == '__main__':
    from pk.widgets import utils
    utils.run_widget(Graph)
Ejemplo n.º 8
0
            self.buttons.append(button)

        self.inputMapper = midi.InputWidget(self)
        self.inputMapper.font().setPointSize(15)
        self.inputMapper.setFixedWidth(110)

        self.metroButton = pk.widgets.Button(self, color="green")
        self.metroButton.setCheckable(True)
        self.metroButton.setText("metro")

        self.steady = pattern.Pattern([pattern.Note(0, 16, 60)])
        self.steady.beats = 1
        self.click = sequencer.Sample()

        ButtonLayout = QHBoxLayout()
        for button in self.buttons:
            ButtonLayout.addWidget(button)
        Layout = QHBoxLayout(self)
        Layout.addWidget(self.label)
        Layout.addStretch(1)
        Layout.addLayout(ButtonLayout)
        Layout.addStretch(1)
        Layout.addWidget(self.metroButton)
        Layout.addWidget(self.inputMapper)


if __name__ == "__main__":
    from pk.widgets.utils import run_widget

    run_widget(MachineControl)