Example #1
0
 def __init__(self, mime, parent=None):
     QWidget.__init__(self, parent)
     self.setFixedWidth(parts.WIDTH + self.margin * 2)
     self.setAutoFillBackground(True)
     self.palette().setColor(self.backgroundRole(),
                             POV_COLOR.light(150))
     self.setAcceptDrops(True)
     self.mime = mime
     self.parts = []
     self.active = True
    def __init__(self, parent=None):
        QFrame.__init__(self, parent)
        self.setAutoFillBackground(True)
        self.palette().setColor(self.backgroundRole(), POV_COLOR)

        resolutions = (('1/16', 16),
                       ('1/8', 8),
                       ('1/4', 4),
                       ('1/2', 2),
                       ('1/1', 1))
        self.resolutions = dict(resolutions)
        
        self.saveButton = pk.widgets.Button(self, color='maroon')
        self.saveButton.setText('save')

        self.nameEdit = QLineEdit(self)
        self.nameEdit.setFixedSize(200, 30)
        self.nameEdit.setAutoFillBackground(True)
        self.nameEdit.palette().setColor(self.nameEdit.backgroundRole(),
                                         POV_COLOR.light(150))
        #self.nameEdit.setAlignment(Qt.AlignCenter)

        self.buttonGroup = QButtonGroup(self)
        self.buttonGroup.setExclusive(True)
        self.buttons = []
        for index, (text, res) in enumerate(resolutions):
            button = pk.widgets.Button(self)
            button.setText(text)
            button.setCheckable(True)
            self.buttonGroup.addButton(button, index)

        self.patternPart = parts.PatternPart(None, self)
    
        self.v_container = QWidget(self)
        self.keyboard = keyboard.Keyboard(self.v_container,
                                          orientation=Qt.Vertical)
        self.keyboard.keywidth = self.keywidth
        self.keyboard.setHalfSteps(HALFSTEPS)
        self.keyboard.setFixedWidth(50)
        self.keyboard.setFixedHeight(HALFSTEPS * self.keywidth)
        self.keyboard.move(0,0)
        
        self.grid = EdittableGrid(self.v_container)
        self.grid.setAutoFillBackground(True)
        self.grid.palette().setColor(self.grid.backgroundRole(),
                                     POV_COLOR.light(150))
        self.grid.set_x_px(5)
        self.grid.set_y_px(self.keywidth)
        self.grid.move(self.keyboard.width(), 0)
        self.grid.setFixedHeight(self.keyboard.height())

        self.v_container.setFixedHeight(self.keyboard.height())
        self.v_scrollarea = QScrollArea(self)
        self.v_scrollarea.setFrameShape(QFrame.StyledPanel)
        self.v_scrollarea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.v_scrollarea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.v_scrollarea.setWidget(self.v_container)
        self.v_scrollarea.setWidgetResizable(True)

        self.v_scrollpad = pk.widgets.ScrollPad(self)
        self.v_scrollpad.setOrientation(Qt.Vertical)
        self.v_scrollpad.setMinimumWidth(spec.SCROLLPAD_WIDTH)
        self.v_scrollpad.set_color(spec.SCROLLPAD_COLOR)
        
        self.h_scrollpad = pk.widgets.ScrollPad(self)
        self.h_scrollpad.setOrientation(Qt.Horizontal)
        self.h_scrollpad.setMinimumHeight(spec.SCROLLPAD_WIDTH)
        self.h_scrollpad.set_color(spec.SCROLLPAD_COLOR)

        QObject.connect(self.buttonGroup, SIGNAL('buttonClicked(int)'),
                        self.set_res)
        QObject.connect(self.v_scrollpad, SIGNAL('valueChanged(int)'),
                        self.v_scroll)
        QObject.connect(self.h_scrollpad, SIGNAL('valueChanged(int)'),
                        self.h_scroll)
        QObject.connect(self.grid, SIGNAL('added()'),
                        self.patternPart.update)
        QObject.connect(self.grid, SIGNAL('deleted()'),
                        self.patternPart.update)
        QObject.connect(self.nameEdit, SIGNAL('textEdited(const QString &)'),
                        self.set_pattern_name)
        QObject.connect(self.saveButton, SIGNAL('clicked()'),
                        self.save_pattern)

        self.buttonGroup.button(1).setChecked(True)
        self.keyboard.raise_()
        self.grid.set_beats(16)
        self.set_res(1)
        self.v_scrollpad.setValue(self.v_scrollpad.maximum() / 2)

        ButtonLayout = QHBoxLayout()
        ButtonLayout.addWidget(self.saveButton)
        ButtonLayout.addWidget(self.nameEdit)
        ButtonLayout.addStretch(2)
        for i, r in enumerate(resolutions):
            ButtonLayout.addWidget(self.buttonGroup.button(i))
        ButtonLayout.addStretch(2)
        ButtonLayout.addWidget(self.patternPart)
        GridLayout = QHBoxLayout()
        GridLayout.addWidget(self.v_scrollarea)
        GridLayout.addWidget(self.v_scrollpad)
        Layout = QVBoxLayout(self)
        Layout.addLayout(ButtonLayout)
        Layout.addLayout(GridLayout)
        Layout.addWidget(self.h_scrollpad)
Example #3
0
#   This program is distributed in the hope that it will be useful,       
#   but WITHOUT ANY WARRANTY; without even the implied warranty of        
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         
#   GNU General Public License for more details.                          
#                                                                         
#   You should have received a copy of the GNU General Public License     
#   along with this program; if not, write to the                         
#   Free Software Foundation, Inc.,                                       
#   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.  
#
"""
constants
"""

import os.path
from PyQt4.QtGui import QColor, QFrame
from pk.widgets.utils import POV_COLOR

SCROLLPAD_WIDTH = 40
SCROLLPAD_COLOR = QColor(255, 0, 255, 200)
FRAME_SHAPE = QFrame.WinPanel
BACKGROUND = POV_COLOR.light(125)
PART_WIDTH = 100
PART_HEIGHT = 55

PKSAMPLER = os.path.join(os.environ['HOME'], '.pksampler')
SAMPLES = os.path.join(PKSAMPLER, 'samples')
LOOPS = os.path.join(PKSAMPLER, 'loops')
PATTERNS = os.path.join(PKSAMPLER, 'patterns')