Browse Source

Experiment a bit with python abc abstractmethod

tags/1.9.5
falkTX 10 years ago
parent
commit
6514a0f8f3
4 changed files with 62 additions and 7 deletions
  1. +11
    -2
      source/carla_patchbay.py
  2. +13
    -2
      source/carla_shared.py
  3. +1
    -1
      source/carla_skin.py
  4. +37
    -2
      source/carla_widgets.py

+ 11
- 2
source/carla_patchbay.py View File

@@ -94,7 +94,7 @@ class PluginInfo(object):
# ------------------------------------------------------------------------------------------------
# Patchbay widget

class CarlaPatchbayW(QFrame):
class CarlaPatchbayW(QFrame, PluginEditParentMeta, metaclass=PyQtMetaClass):
def __init__(self, parent, doSetup = True, onlyPatchbay = True, is3D = False):
QFrame.__init__(self, parent)

@@ -391,10 +391,19 @@ class CarlaPatchbayW(QFrame):
# -----------------------------------------------------------------
# called by PluginEdit to plugin skin parent, ignored here

def recheckPluginHints(self, hints):
pass

def editDialogChanged(self, visible):
pass

def recheckPluginHints(self, hints):
def parameterValueChanged(self, parameterId, value):
pass

def programChanged(self, index):
pass

def midiProgramChanged(self, index):
pass

def notePressed(self, note):


+ 13
- 2
source/carla_shared.py View File

@@ -29,14 +29,19 @@ import sys

if config_UseQt5:
from PyQt5.Qt import PYQT_VERSION_STR
from PyQt5.QtCore import qFatal, qVersion, qWarning, QDir
from PyQt5.QtCore import pyqtWrapperType, qFatal, qVersion, qWarning, QDir
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QFileDialog, QMessageBox
else:
from PyQt4.Qt import PYQT_VERSION_STR
from PyQt4.QtCore import qFatal, qVersion, qWarning, QDir
from PyQt4.QtCore import pyqtWrapperType, qFatal, qVersion, qWarning, QDir
from PyQt4.QtGui import QFileDialog, QIcon, QMessageBox

# ------------------------------------------------------------------------------------------------------------
# Import ABC

from abc import ABCMeta, abstractmethod

# ------------------------------------------------------------------------------------------------------------
# Import Signal

@@ -636,3 +641,9 @@ def CustomMessageBox(parent, icon, title, text, extraText="", buttons=QMessageBo
return msgBox.exec_()

# ------------------------------------------------------------------------------------------------------------
# An empty class used to resolve metaclass conflicts between ABC and PyQt modules

class PyQtMetaClass(pyqtWrapperType, ABCMeta):
pass

# ------------------------------------------------------------------------------------------------------------

+ 1
- 1
source/carla_skin.py View File

@@ -47,7 +47,7 @@ from pixmapdial import PixmapDial
# ------------------------------------------------------------------------------------------------------------
# Abstract plugin slot

class AbstractPluginSlot(QFrame):
class AbstractPluginSlot(QFrame, PluginEditParentMeta, metaclass=PyQtMetaClass):
def __init__(self, parent, pluginId):
QFrame.__init__(self, parent)



+ 37
- 2
source/carla_widgets.py View File

@@ -25,11 +25,11 @@ from carla_config import *
# Imports (Global)

if config_UseQt5:
from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QByteArray, QSettings, QTimer
from PyQt5.QtCore import pyqtSignal, pyqtSlot, pyqtWrapperType, Qt, QByteArray, QSettings, QTimer
from PyQt5.QtGui import QColor, QCursor, QFontMetrics, QPainter, QPainterPath
from PyQt5.QtWidgets import QDialog, QInputDialog, QLineEdit, QMenu, QVBoxLayout, QWidget
else:
from PyQt4.QtCore import pyqtSignal, pyqtSlot, Qt, QByteArray, QSettings, QTimer
from PyQt4.QtCore import pyqtSignal, pyqtSlot, pyqtWrapperType, Qt, QByteArray, QSettings, QTimer
from PyQt4.QtGui import QColor, QCursor, QFontMetrics, QPainter, QPainterPath
from PyQt4.QtGui import QDialog, QInputDialog, QLineEdit, QMenu, QVBoxLayout, QWidget

@@ -394,6 +394,38 @@ class PluginParameter(QWidget):
def _textCallBack(self):
return gCarla.host.get_parameter_text(self.fPluginId, self.fParameterId)

# ------------------------------------------------------------------------------------------------------------
# Plugin Editor Parent (Meta class)

class PluginEditParentMeta(metaclass=ABCMeta):
@abstractmethod
def recheckPluginHints(self, hints):
raise NotImplementedError

@abstractmethod
def editDialogChanged(self, visible):
raise NotImplementedError

@abstractmethod
def parameterValueChanged(self, parameterId, value):
raise NotImplementedError

@abstractmethod
def programChanged(self, index):
raise NotImplementedError

@abstractmethod
def midiProgramChanged(self, index):
raise NotImplementedError

@abstractmethod
def notePressed(self, note):
raise NotImplementedError

@abstractmethod
def noteReleased(self, note):
raise NotImplementedError

# ------------------------------------------------------------------------------------------------------------
# Plugin Editor (Built-in)

@@ -405,6 +437,9 @@ class PluginEdit(QDialog):
self.ui = ui_carla_edit.Ui_PluginEdit()
self.ui.setupUi(self)

if False:
parent = PluginEditParent()

# -------------------------------------------------------------
# Internal stuff



Loading…
Cancel
Save