コード例 #1
0
    def __init__(self, parent):
        QWidget.__init__(self, parent)
        self.freqMin = 87.5
        self.freqMax = 108

        self.d_sliderFrequency = Qwt.QwtSlider(self)
        self.d_sliderFrequency.setOrientation(Qt.Horizontal)
        self.d_sliderFrequency.setScalePosition(Qwt.QwtSlider.TrailingScale)
        self.d_sliderFrequency.setScale(self.freqMin, self.freqMax)
        #self.d_sliderFrequency.setTotalSteps( math.round( ( self.freqMax - self.freqMin ) / 0.01 ) ) FIXME
        self.d_sliderFrequency.setTotalSteps(
            int(math.ceil((self.freqMax - self.freqMin) / 0.01)))
        self.d_sliderFrequency.setSingleSteps(1)
        self.d_sliderFrequency.setPageSteps(10)
        self.d_sliderFrequency.setScaleMaxMinor(5)
        self.d_sliderFrequency.setScaleMaxMajor(12)
        self.d_sliderFrequency.setHandleSize(QSize(80, 20))
        self.d_sliderFrequency.setBorderWidth(1)

        self.d_thermoTune = TuningThermo(self)

        self.d_wheelFrequency = Qwt.QwtWheel(self)
        self.d_wheelFrequency.setMass(0.5)
        self.d_wheelFrequency.setRange(87.5, 108)
        self.d_wheelFrequency.setSingleStep(0.01)
        self.d_wheelFrequency.setPageStepCount(10)
        self.d_wheelFrequency.setTotalAngle(3600.0)
        self.d_wheelFrequency.setFixedHeight(30)

        self.d_wheelFrequency.valueChanged['double'].connect(self.adjustFreq)
        self.d_sliderFrequency.valueChanged['double'].connect(self.adjustFreq)

        self.mainLayout = QVBoxLayout(self)
        #self.mainLayout.setMargin( 10 )
        self.mainLayout.setSpacing(5)
        self.mainLayout.addWidget(self.d_sliderFrequency)

        self.hLayout = QHBoxLayout()
        #self.hLayout.setMargin( 0 )
        #self.hLayout.addWidget( self.d_thermoTune, 0 )
        self.hLayout.addStretch(5)
        self.hLayout.addWidget(self.d_wheelFrequency, 2)

        self.mainLayout.addLayout(self.hLayout)
コード例 #2
0
ファイル: controls.py プロジェクト: tonglingwen/PyQt-Qwt
 def createSlider(self, sliderType):
     slider = Qwt.QwtSlider()
     if sliderType == 0:
         slider.setOrientation(Qt.Horizontal)
         slider.setScalePosition(Qwt.QwtSlider.TrailingScale)
         slider.setTrough(True)
         slider.setGroove(False)
         slider.setSpacing(0)
         slider.setHandleSize(QSize(30, 16))
         slider.setScale(10.0, -10.0)
         slider.setTotalSteps(8)
         slider.setSingleSteps(1)
         slider.setPageSteps(1)
         slider.setWrapping(True)
     elif sliderType == 1:
         slider.setOrientation(Qt.Horizontal)
         slider.setScalePosition(Qwt.QwtSlider.NoScale)
         slider.setTrough(True)
         slider.setGroove(True)
         slider.setScale(0.0, 1.0)
         slider.setTotalSteps(100)
         slider.setSingleSteps(1)
         slider.setPageSteps(5)
     elif sliderType == 2:
         slider.setOrientation(Qt.Horizontal)
         slider.setScalePosition(Qwt.QwtSlider.LeadingScale)
         slider.setTrough(False)
         slider.setGroove(True)
         slider.setHandleSize(QSize(12, 25))
         slider.setScale(1000.0, 3000.0)
         slider.setTotalSteps(200.0)
         slider.setSingleSteps(2)
         slider.setPageSteps(10)
     elif sliderType == 3:
         slider.setOrientation(Qt.Horizontal)
         slider.setScalePosition(Qwt.QwtSlider.TrailingScale)
         slider.setTrough(True)
         slider.setGroove(True)
         scaleEngine = Qwt.QwtLinearScaleEngine(2)
         scaleEngine.setTransformation(Qwt.QwtPowerTransform(2))
         slider.setScaleEngine(scaleEngine)
         slider.setScale(0.0, 128.0)
         slider.setTotalSteps(100)
         slider.setStepAlignment(False)
         slider.setSingleSteps(1)
         slider.setPageSteps(5)
     elif sliderType == 4:
         slider.setOrientation(Qt.Vertical)
         slider.setScalePosition(Qwt.QwtSlider.TrailingScale)
         slider.setTrough(False)
         slider.setGroove(True)
         slider.setScale(100.0, 0.0)
         slider.setInvertedControls(True)
         slider.setTotalSteps(100)
         slider.setPageSteps(5)
         slider.setScaleMaxMinor(5)
     elif sliderType == 5:
         slider.setOrientation(Qt.Vertical)
         slider.setScalePosition(Qwt.QwtSlider.NoScale)
         slider.setTrough(True)
         slider.setGroove(False)
         slider.setScale(0.0, 100.0)
         slider.setTotalSteps(100)
         slider.setPageSteps(10)
     elif sliderType == 6:
         slider.setOrientation(Qt.Vertical)
         slider.setScalePosition(Qwt.QwtSlider.LeadingScale)
         slider.setTrough(True)
         slider.setGroove(True)
         slider.setScaleEngine(Qwt.QwtLogScaleEngine())
         slider.setStepAlignment(False)
         slider.setHandleSize(QSize(20, 32))
         slider.setBorderWidth(1)
         slider.setScale(1.0, 1.0e4)
         slider.setTotalSteps(100)
         slider.setPageSteps(10)
         slider.setScaleMaxMinor(9)
     if (slider):
         slider.setObjectName("Slider %d" % sliderType)
     return slider