def __init__(self, parent=None): Qwt.QwtDial.__init__(self, parent) self.d_gradient = 0.0 scaleDraw = Qwt.QwtRoundScaleDraw() scaleDraw.enableComponent(Qwt.QwtAbstractScaleDraw.Backbone, False) scaleDraw.enableComponent(Qwt.QwtAbstractScaleDraw.Labels, False) self.setScaleDraw(scaleDraw) #self.setMode( Qwt.RotateScale ) self.setWrapping(True) self.setOrigin(270.0) self.setScaleMaxMinor(0) self.setScaleStepSize(30.0) self.setScale(0.0, 360.0) color = self.palette().color(QPalette.Text) self.setNeedle(AttitudeIndicatorNeedle(color))
def __init__(self, parent=None): Qwt.QwtDial.__init__(self, parent) self.d_label = "km/h" scaleDraw = Qwt.QwtRoundScaleDraw() scaleDraw.setSpacing(8) scaleDraw.enableComponent(Qwt.QwtAbstractScaleDraw.Backbone, False) scaleDraw.setTickLength(Qwt.QwtScaleDiv.MinorTick, 0) scaleDraw.setTickLength(Qwt.QwtScaleDiv.MediumTick, 4) scaleDraw.setTickLength(Qwt.QwtScaleDiv.MajorTick, 8) self.setScaleDraw(scaleDraw) self.setWrapping(False) self.setReadOnly(True) self.setOrigin(135.0) self.setScaleArc(0.0, 270.0) needle = Qwt.QwtDialSimpleNeedle(Qwt.QwtDialSimpleNeedle.Arrow, True, Qt.red, QColor(Qt.gray)) #.light( 130 ) ) self.setNeedle(needle)
def __init__(self, label="", min_val=-90, max_val=90, step=10, arc_bias=0, *args): gr.sync_block.__init__(self,name="QT Compass",in_sig=[numpy.float32],out_sig=[]) Qt.QWidget.__init__(self, *args) # Set parameters self.update_period = 0.1 self.last = time.time() self.next_angle = 0 ### QT STUFF # Setup overall layouts self.this_layout = QtWidgets.QVBoxLayout(self) self.compass_layout = QtWidgets.QGridLayout() # Setup Dial self.dial = Qwt.QwtDial(self) self.dial.setOrigin(180+arc_bias) # Orient dial so 0 is at 9 o'clock self.dial.setScaleArc(float(min_val), float(max_val)) scaleDraw = Qwt.QwtRoundScaleDraw() scaleDraw.setSpacing(8) scaleDraw.setTickLength(Qwt.QwtScaleDiv.MinorTick, 0) scaleDraw.setTickLength(Qwt.QwtScaleDiv.MediumTick, 4) scaleDraw.setTickLength(Qwt.QwtScaleDiv.MajorTick, 8) self.dial.setScaleDraw(scaleDraw) self.dial.setScale(min_val ,max_val) # Add needle self.dial.setNeedle(Qwt.QwtDialSimpleNeedle( Qwt.QwtDialSimpleNeedle.Arrow, True, QtGui.QColor(QtCore.Qt.red), QtGui.QColor(QtCore.Qt.gray).lighter(130))) self.dial.setValue(0) # Set sizing self.dial.setMinimumSize(250,250) self.dial.setSizePolicy(Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Expanding) # Add to overall layout self.compass_layout.addWidget(self.dial,0,0) # Add label self.label = Qt.QLabel(label) font = QtGui.QFont() font.setPointSize(14) font.setBold(True) self.label.setFont(font) self.label.setAlignment(QtCore.Qt.AlignCenter) self.this_layout.addWidget(self.label) self.this_layout.addLayout(self.compass_layout) # Setup LCD lcd_layout = QtWidgets.QGridLayout() self.lcd = QtWidgets.QLCDNumber(self) sizePolicy = Qt.QSizePolicy(Qt.QSizePolicy.Preferred, Qt.QSizePolicy.Preferred) sizePolicy.setHeightForWidth(True) self.lcd.setSizePolicy(sizePolicy) self.lcd.setLineWidth(0) # Set sizing self.lcd.setMinimumHeight(self.dial.minimumHeight()/2) self.lcd.setMinimumWidth(self.dial.minimumWidth()/2) self.lcd.raise_() # Bring to front self.lcd.setDigitCount(3) # Max digits displayed self.lcd.setSmallDecimalPoint(True) self.lcd.display(123.4) self.this_layout.addLayout(lcd_layout) lcd_layout.addWidget(self.lcd,1,1,1,1) # Add spacers to center LCD spacerTop = QtWidgets.QSpacerItem(1,300,Qt.QSizePolicy.Maximum,Qt.QSizePolicy.Expanding) spacerSides = QtWidgets.QSpacerItem(220,1,Qt.QSizePolicy.Maximum,Qt.QSizePolicy.Expanding) spacerBottom = QtWidgets.QSpacerItem(1,150,Qt.QSizePolicy.Maximum,Qt.QSizePolicy.Expanding) # Top Spacers #lcd_layout.addItem(spacerTop,0,1,1,1) # Side Spacers lcd_layout.addItem(spacerSides,1,0,1,1) lcd_layout.addItem(spacerSides,1,2,1,1) # Bottom Spacers #lcd_layout.addItem(spacerBottom,2,1,1,1) self.label.raise_() # connect the plot callback signal self.valueChanged.connect(self.do_plot)
def __init__(self): super(MyApp, self).__init__() # Set up the user interface from Designer. self.ui = Ui_mainWindow() self.ui.setupUi(self) # ======= LOCAL WIDGET MODIFICATIONS =============================================================== spdMeter = self.ui.SpeedDial spdLCD = self.ui.SpeedLCD spdWheel = self.ui.SpeedWheel thermo = self.ui.Thermo thermSlide = self.ui.ThermoSlider compass = self.ui.Compass counter = self.ui.Counter global clk clk = self.ui.AnalogClock # SPEEDOMETER SETUP palette2 = QPalette() palette2.setColor(QPalette.Base, Qt.black) palette2.setColor(QPalette.WindowText, QColor(Qt.darkBlue)) palette2.setColor(QPalette.Text, Qt.yellow) palette2.setColor(QPalette.Dark, Qt.darkGray) # Bezel ring color 1 palette2.setColor(QPalette.Light, Qt.lightGray) # Bezel Ring Color 2 spdMeter.setPalette(palette2) needle = Qwt.QwtDialSimpleNeedle(Qwt.QwtDialSimpleNeedle.Arrow, True, Qt.red, QtGui.QColor(Qt.gray)) spdMeter.setNeedle(needle) # THERMO SETUP colorMap = Qwt.QwtLinearColorMap() colorMap.setColorInterval(Qt.blue, Qt.red) thermo.setColorMap(colorMap) # COMPASS SETUP palette0 = QPalette() palette0.setColor(QPalette.Base, Qt.darkBlue) palette0.setColor(QPalette.WindowText, QColor(Qt.darkBlue)) palette0.setColor(QPalette.Text, Qt.yellow) palette0.setColor(QPalette.Dark, Qt.darkGray) # Bezel ring color 1 palette0.setColor(QPalette.Light, Qt.lightGray) # Bezel Ring Color 2 compass.setPalette(palette0) # Tick marks for each degree CompSclDrw = Qwt.QwtCompassScaleDraw() CompSclDrw.enableComponent(Qwt.QwtAbstractScaleDraw.Ticks, True) CompSclDrw.enableComponent(Qwt.QwtAbstractScaleDraw.Labels, True) CompSclDrw.enableComponent(Qwt.QwtAbstractScaleDraw.Backbone, False) CompSclDrw.setTickLength(Qwt.QwtScaleDiv.MinorTick, 0) CompSclDrw.setTickLength(Qwt.QwtScaleDiv.MediumTick, 0) CompSclDrw.setTickLength(Qwt.QwtScaleDiv.MajorTick, 5) compass.setScaleDraw(CompSclDrw) compass.setNeedle(Qwt.QwtCompassMagnetNeedle(Qwt.QwtCompassMagnetNeedle.ThinStyle, Qt.darkBlue, Qt.red)) # ANALOG CLOCK SETUP palette1 = QPalette() palette1.setColor(QPalette.Base, Qt.black) # Clock number ring background palette1.setColor(QPalette.Text, Qt.yellow) # Clock numbers color palette1.setColor(QPalette.Foreground, Qt.darkBlue) # Inner Ring Color palette1.setColor(QPalette.Dark, Qt.darkGray) # Bezel ring color 1 palette1.setColor(QPalette.Light, Qt.lightGray) # Bezel Ring Color 2 clk.setPalette(palette1) # Disable minor ticks ClkSclDrw = Qwt.QwtRoundScaleDraw() ClkSclDrw.setTickLength(Qwt.QwtScaleDiv.MinorTick, 0) # Set color of clock hands knobColor = QColor(Qt.gray) for i in range(clk.NHands): handColor = QColor(Qt.gray) width = 8 if i == clk.SecondHand: handColor = Qt.red knobColor = QColor(Qt.darkRed) width = 5 hand = Qwt.QwtDialSimpleNeedle(Qwt.QwtDialSimpleNeedle.Arrow, True, handColor, knobColor) hand.setWidth(width) clk.setHand(clk.Hand(i), hand) # ======= WIDGET CONNECTIONS ======================================================================= spdMeter.setValue(self.ui.SpeedWheel.value()) spdWheel.valueChanged['double'].connect(spdMeter.setValue) spdWheel.valueChanged['double'].connect(spdLCD.display) thermSlide.valueChanged['double'].connect(thermo.setValue) counter.valueChanged['double'].connect(compass.setValue) # ======= SINE WAVE PLOT SETUP ==================================================================== global ampKnob, frqKnob, maxPts, n, angle, xData, yData, curve, plot, deg ampKnob = self.ui.AmpKnob # Amplitude knob object frqKnob = self.ui.FreqKnob # Frequency knob object maxPts = 250 # X axis range for plots xData = np.zeros(1, dtype=np.uint16) # Buffer for x data yData = np.zeros(1, dtype=np.float32) # Buffer for y Data n = 0 # loop counter and base for frequency steps angle = 0 # Rotation angle along X axis for plots deg = u'\N{DEGREE SIGN}' plot = self.ui.qwtPlot # Plot object # plot.setTitle("SINE WAVE PLOT") # plot.insertLegend(Qwt.QwtLegend()) plot.setCanvasBackground(Qt.black) plot.setAxisScale(2, 0, maxPts, 50) # X bottom axis plot.setAxisMaxMinor(2, 5) plot.setAxisScale(0, -10, 10, 2) # Y Left Axis plot.setAxisMaxMinor(0, 2) grid = Qwt.QwtPlotGrid() grid.setPen(Qt.darkGray, 0, Qt.DotLine) grid.attach(plot) curve = Qwt.QwtPlotCurve() # curve.setTitle("Some Points") curve.attach(plot) curve.setPen(Qt.yellow, 2) curve.setRenderHint(Qwt.QwtPlotItem.RenderAntialiased, True) # Start the loop function update()