diff --git a/orangecontrib/spectroscopy/widgets/preprocessors/misc.py b/orangecontrib/spectroscopy/widgets/preprocessors/misc.py index 9b1934250..53b7ace97 100644 --- a/orangecontrib/spectroscopy/widgets/preprocessors/misc.py +++ b/orangecontrib/spectroscopy/widgets/preprocessors/misc.py @@ -3,13 +3,12 @@ from AnyQt.QtCore import Qt from AnyQt.QtWidgets import ( - QComboBox, QSpinBox, QVBoxLayout, QHBoxLayout, QFormLayout, QSizePolicy, QLabel + QComboBox, QVBoxLayout, QHBoxLayout, QFormLayout, QLabel ) from AnyQt.QtGui import QColor from Orange.widgets import gui from Orange.widgets.widget import Msg -from Orange.widgets.data.owpreprocess import blocked from orangecontrib.spectroscopy.data import getx @@ -21,7 +20,7 @@ from orangecontrib.spectroscopy.preprocess.transform import SpecTypes from orangecontrib.spectroscopy.widgets.gui import lineEditFloatRange, MovableVline, \ connect_line, floatornone, round_virtual_pixels -from orangecontrib.spectroscopy.widgets.preprocessors.utils import BaseEditor, BaseEditorOrange, \ +from orangecontrib.spectroscopy.widgets.preprocessors.utils import BaseEditorOrange, \ REFERENCE_DATA_PARAM from orangecontrib.spectroscopy.widgets.preprocessors.registry import preprocess_editors @@ -325,47 +324,33 @@ def createinstance(params): return CurveShift(amount=amount) -class PCADenoisingEditor(BaseEditor): +class PCADenoisingEditor(BaseEditorOrange): name = "PCA denoising" qualname = "orangecontrib.infrared.pca_denoising" def __init__(self, parent=None, **kwargs): - BaseEditor.__init__(self, parent, **kwargs) - self.__components = 5 + super().__init__(parent, **kwargs) + + self.components = 5 form = QFormLayout() + self.controlArea.setLayout(form) - self.__compspin = compspin = QSpinBox( - minimum=1, maximum=100, value=self.__components) + compspin = gui.spin(self, self, "components", minv=1, maxv=100, + step=1, callback=self._components_edited) endlabel = QLabel("components.") hboxLayout = QHBoxLayout() - hboxLayout.addWidget(self.__compspin) + hboxLayout.addWidget(compspin) hboxLayout.addWidget(endlabel) form.addRow("Keep", hboxLayout) - self.setLayout(form) - - compspin.valueChanged[int].connect(self.setComponents) - compspin.editingFinished.connect(self.edited) - self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred) - - def setComponents(self, components): - if self.__components != components: - self.__components = components - with blocked(self.__compspin): - self.__compspin.setValue(components) - self.changed.emit() - - def sd(self): - return self.__components + def _components_edited(self): + self.edited.emit() def setParameters(self, params): - self.setComponents(params.get("components", 5)) - - def parameters(self): - return {"components": self.__components} + self.components = params.get("components", 5) @staticmethod def createinstance(params):