def __init__(self, title, min, max, parent): super().__init__(parent) QWidget = parent font = QFont("Helvetica", 10) self.__d_knob = Qwt.QwtKnob(self) self.__d_knob.setFont(font) scaleDiv = self.__d_knob.scaleEngine().divideScale(min, max, 5, 3) ticks = scaleDiv.ticks(Qwt.QwtScaleDiv.MajorTick) if (len(ticks) > 0 and ticks[0] > min): if (ticks[0] > min): ticks.insert(0, min) if (ticks[-1] < max): ticks.append(max) scaleDiv.setTicks(Qwt.QwtScaleDiv.MajorTick, ticks) self.__d_knob.setScale(scaleDiv) self.__d_knob.setKnobWidth(50) font.setBold(True) self.__d_label = QLabel(title, self) self.__d_label.setFont(font) self.__d_label.setAlignment(Qt.AlignTop | Qt.AlignHCenter) self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) self.__d_knob.valueChanged.connect(self.valueChanged)
def createKnob(self, knobType): knob = Qwt.QwtKnob() knob.setTracking(True) if knobType == 0: knob.setKnobStyle(Qwt.QwtKnob.Sunken) knob.setMarkerStyle(Qwt.QwtKnob.Nub) knob.setWrapping(True) knob.setNumTurns(4) knob.setScaleStepSize(10.0) knob.setScale(0, 400) knob.setTotalSteps(400) elif knobType == 1: knob.setKnobStyle(Qwt.QwtKnob.Sunken) knob.setMarkerStyle(Qwt.QwtKnob.Dot) elif knobType == 2: knob.setKnobStyle(Qwt.QwtKnob.Sunken) knob.setMarkerStyle(Qwt.QwtKnob.Tick) #QwtLinearScaleEngine *scaleEngine = new QwtLinearScaleEngine( 2 ) #scaleEngine.setTransformation( new QwtPowerTransform( 2 ) ) #knob.setScaleEngine( scaleEngine ) """QList< double > ticks[ QwtScaleDiv.NTickTypes ] ticks[ QwtScaleDiv.MajorTick ] << 0 << 4 << 16 << 32 << 64 << 96 << 128 ticks[ QwtScaleDiv.MediumTick ] << 24 << 48 << 80 << 112 ticks[ QwtScaleDiv.MinorTick ] << 0.5 << 1 << 2 << 7 << 10 << 13 << 20 << 28 << 40 << 56 << 72 << 88 << 104 << 120 knob.setScale( QwtScaleDiv( 0, 128, ticks ) )""" knob.setTotalSteps(100) knob.setStepAlignment(False) knob.setSingleSteps(1) knob.setPageSteps(5) elif knobType == 3: knob.setKnobStyle(Qwt.QwtKnob.Flat) knob.setMarkerStyle(Qwt.QwtKnob.Notch) knob.setScaleEngine(Qwt.QwtLogScaleEngine()) knob.setScaleStepSize(1.0) knob.setScale(0.1, 1000.0) knob.setScaleMaxMinor(10) elif knobType == 4: knob.setKnobStyle(Qwt.QwtKnob.Raised) knob.setMarkerStyle(Qwt.QwtKnob.Dot) knob.setWrapping(True) elif knobType == 5: knob.setKnobStyle(Qwt.QwtKnob.Styled) knob.setMarkerStyle(Qwt.QwtKnob.Triangle) knob.setTotalAngle(180.0) knob.setScale(100, -100) return knob
def __init__(self, title, min, max, parent): QWidget.__init__(self, parent) self.d_knob = Qwt.QwtKnob(self) self.d_knob.setScale(min, max) self.d_knob.setTotalSteps(0) # disable self.d_knob.setScaleMaxMajor(10) self.d_knob.setKnobStyle(Qwt.QwtKnob.Raised) self.d_knob.setKnobWidth(50) self.d_knob.setBorderWidth(2) self.d_knob.setMarkerStyle(Qwt.QwtKnob.Notch) self.d_knob.setMarkerSize(8) self.d_knob.scaleDraw().setTickLength(Qwt.QwtScaleDiv.MinorTick, 4) self.d_knob.scaleDraw().setTickLength(Qwt.QwtScaleDiv.MediumTick, 4) self.d_knob.scaleDraw().setTickLength(Qwt.QwtScaleDiv.MajorTick, 6) self.d_label = QLabel(title, self) self.d_label.setAlignment(Qt.AlignTop | Qt.AlignHCenter) self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)