def __init__(self, logger, canvas_height=2, canvas_width=2): QtCore.QObject.__init__(self) # store the logger instance self.logger = logger self.canvas_height = canvas_height self.canvas_width = canvas_width #self.fullspectrogram = numpy.zeros((self.canvas_height, self.time_bin_number(), 4), dtype = numpy.uint8) self.pixmap = QtGui.QPixmap(2 * self.canvas_width, self.canvas_height) #print "pixmap info : hasAlpha =", self.pixmap.hasAlpha(), ", depth =", self.pixmap.depth(), ", default depth =", self.pixmap.defaultDepth() self.pixmap.fill(QtGui.QColor("black")) self.painter = QtGui.QPainter() self.offset = 0 # prepare a custom colormap black->blue->green->yellow->red->white self.colorMap = Qwt.QwtLinearColorMap(Qt.Qt.black, Qt.Qt.white) self.colorMap.addColorStop(0.2, Qt.Qt.blue) self.colorMap.addColorStop(0.4, Qt.Qt.green) self.colorMap.addColorStop(0.6, Qt.Qt.yellow) self.colorMap.addColorStop(0.8, Qt.Qt.red) self.prepare_palette() # performance timer self.time = QtCore.QTime() self.time.start()
def log_check(self, log, replot=True): self.log = log min_intes = self.data.intes_array.min() max_intes = math.ceil(self.data.intes_array.max()) + 1.0 if log: # most of this is changing color scaling for logarithimc colorMap = Qwt.QwtLinearColorMap(Qt.Qt.darkCyan, Qt.Qt.red) if min_intes <= 0: logmin = 0.01 else: logmin = min_intes self.setAxisScale(Qwt.QwtPlot.yRight, logmin, max_intes) oom = int( math.log10(max_intes) ) # for log scale we will add in colours depnding on order of magnatiude (oom) map = [[1.0 / (10**oom), Qt.Qt.cyan], [0.1, Qt.Qt.yellow], [0.01, Qt.Qt.darkGreen], [1.0 / (10**(oom - 1)), Qt.Qt.blue], [1.0 / (10**(oom - 2)), Qt.Qt.darkBlue], [1.0 / (10**(oom - 3)), Qt.Qt.green]] for i in range(oom): colorMap.addColorStop(map[i][0], map[i][1]) self.__spectrogram.setColorMap(colorMap) self.setAxisScaleEngine(Qwt.QwtPlot.yRight, Qwt.QwtLog10ScaleEngine()) else: colorMap = Qwt.QwtLinearColorMap(Qt.Qt.darkCyan, Qt.Qt.red) self.setAxisScale(Qwt.QwtPlot.yRight, math.floor(min_intes), math.ceil(max_intes)) colorMap.addColorStop(0.25, Qt.Qt.cyan) colorMap.addColorStop(0.5, Qt.Qt.darkGreen) colorMap.addColorStop(0.75, Qt.Qt.yellow) self.setAxisScaleEngine(Qwt.QwtPlot.yRight, Qwt.QwtLinearScaleEngine()) self.__spectrogram.setColorMap(colorMap) self.__spectrogram.attach(self) rightAxis = self.axisWidget(Qwt.QwtPlot.yRight) rightAxis.setTitle("Intensity") rightAxis.setColorBarEnabled(True) rightAxis.setColorMap(self.__spectrogram.data().range(), self.__spectrogram.colorMap()) self.enableAxis(Qwt.QwtPlot.yRight) if replot: self.replot()
def plot(self, x=None, y=None, z=None): if (x == None or x == True or x == False) and y == None and z == None: x, y, z = self.old_x, self.old_y, self.old_z else: self.old_x, self.old_y, self.old_z = x, y, z if all(p == x[0] for p in x) or all(p == y[0] for p in y):# is data 1D? xy = [x, y] for i, k in enumerate(xy): try: if k[0] == k[1]: xy[i].extend([q+0.1 for q in xy[i]]) else: xy[i].extend(xy[i]) except IndexError: continue z.extend(z) self.data = SpectrogramData(x, y, z) # self.data.sizeHint(Qt.QSize(1000,1000)) self.__spectrogram.setData(self.data) zero_data = filter(lambda a: a != 0, self.data.intes) min_intes = int(min(zero_data)) max_intes = int(math.ceil(self.data.intes_array.max())) # size_intes = abs(max_intes - min_intes) colorMap = Qwt.QwtLinearColorMap(Qt.Qt.darkCyan, Qt.Qt.red) colorMap.addColorStop(0.25, Qt.Qt.cyan) colorMap.addColorStop(0.5, Qt.Qt.darkGreen) colorMap.addColorStop(0.75, Qt.Qt.yellow) self.__spectrogram.setColorMap(colorMap) self.__spectrogram.attach(self) self.setAxisScale(Qwt.QwtPlot.yRight, math.floor(min_intes), math.ceil(max_intes)) # heightlist = [] # for h in [0.1, 0.2, .25, .35, .45, .55, .65, .75, .85, .95]: # heightlist.append(min_intes + size_intes * h) # # self.__spectrogram.setContourLevels( # # [0.1, 0.2, .25, .35, .45, .55, .65, .75, .85, .95]) # heightlist) # # self.plotLayout().setAlignCanvasToScales(True) print "Zoom level = ", self.zoomer.zoomRectIndex() if self.zoomer.zoomRectIndex() == 0: self.autoscale() else: self.__spectrogram.invalidateCache() self.replot()
def __init__(self, parent=None): Qwt.QwtPlot.__init__(self, parent) self.__spectrogram = Qwt.QwtPlotSpectrogram() colorMap = Qwt.QwtLinearColorMap(Qt.Qt.darkCyan, Qt.Qt.red) colorMap.addColorStop(0.1, Qt.Qt.cyan) colorMap.addColorStop(0.6, Qt.Qt.green) colorMap.addColorStop(0.95, Qt.Qt.yellow) self.__spectrogram.setColorMap(colorMap) self.__spectrogram.setData(SpectrogramData()) self.__spectrogram.attach(self) self.__spectrogram.setContourLevels( [0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5]) rightAxis = self.axisWidget(Qwt.QwtPlot.yRight) rightAxis.setTitle("Intensity") rightAxis.setColorBarEnabled(True) rightAxis.setColorMap(self.__spectrogram.data().range(), self.__spectrogram.colorMap()) self.setAxisScale(Qwt.QwtPlot.yRight, self.__spectrogram.data().range().minValue(), self.__spectrogram.data().range().maxValue()) self.enableAxis(Qwt.QwtPlot.yRight) self.plotLayout().setAlignCanvasToScales(True) self.replot() # LeftButton for the zooming # MidButton for the panning # RightButton: zoom out by 1 # Ctrl+RighButton: zoom out to full size zoomer = Qwt.QwtPlotZoomer(self.canvas()) zoomer.setMousePattern(Qwt.QwtEventPattern.MouseSelect2, Qt.Qt.RightButton, Qt.Qt.ControlModifier) zoomer.setMousePattern(Qwt.QwtEventPattern.MouseSelect3, Qt.Qt.RightButton) zoomer.setRubberBandPen(Qt.Qt.darkBlue) zoomer.setTrackerPen(Qt.Qt.darkBlue) panner = Qwt.QwtPlotPanner(self.canvas()) panner.setAxisEnabled(Qwt.QwtPlot.yRight, False) panner.setMouseButton(Qt.Qt.MidButton) # Avoid jumping when labels with more/less digits # appear/disappear when scrolling vertically fm = Qt.QFontMetrics(self.axisWidget(Qwt.QwtPlot.yLeft).font()) self.axisScaleDraw(Qwt.QwtPlot.yLeft).setMinimumExtent( fm.width("100.00"))
def __init__(self, parent=None, **kwargs): """ :Parameters: parent : QObject QT parent. cmap : tuple colormap tuples. [0] from (req.), [1] to (req), [2:] color stops as (stop, qt-color) """ # super super(MatShow, self).__init__(parent) # layout self.plotLayout().setMargin(0) self.plotLayout().setCanvasMargin(0) self.plotLayout().setAlignCanvasToScales(True) self.setFrameStyle(QtGui.QFrame.NoFrame) self.setLineWidth(0) self.setCanvasLineWidth(0) self.setAutoReplot(False) # matplot cmap = kwargs.get('cmap', (QtCore.Qt.white, QtCore.Qt.blue)) colmap = Qwt5.QwtLinearColorMap(cmap[0], cmap[1]) if len(cmap) > 2: for item in cmap[2:]: colmap.addColorStop(item[0], item[1]) self._mat = Qwt5.QwtPlotSpectrogram() self._mat.setColorMap(colmap) self._mat.attach(self) # matdata self._data = MatrixData() self._mat.setData(self._data) # axis and scales self.axisWidget(Qwt5.QwtPlot.yRight).setColorBarEnabled(True) self.enableAxis(Qwt5.QwtPlot.yRight, True) self.enableAxis(Qwt5.QwtPlot.yLeft, True) self.enableAxis(Qwt5.QwtPlot.xTop, False) self.enableAxis(Qwt5.QwtPlot.xBottom, True)
def __init__(self, qapp, filename, options, parent=None): QtGui.QWidget.__init__(self, parent) self.gui = Ui_MainWindow() self.gui.setupUi(self) self.filename = None self.block_length = options.block_length self.start = options.start self.sample_rate = options.sample_rate self.psdfftsize = options.psd_size self.specfftsize = options.spec_size self.winfunc = scipy.blackman self.sizeof_data = 8 self.datatype = scipy.complex64 self.pen_width = 1 self.iq = list() self.time = list() # Set up basic plot attributes self.gui.timePlot.setAxisTitle(self.gui.timePlot.xBottom, "Time (sec)") self.gui.timePlot.setAxisTitle(self.gui.timePlot.yLeft, "Amplitude (V)") self.gui.freqPlot.setAxisTitle(self.gui.freqPlot.xBottom, "Frequency (Hz)") self.gui.freqPlot.setAxisTitle(self.gui.freqPlot.yLeft, "Magnitude (dB)") self.gui.specPlot.setAxisTitle(self.gui.specPlot.xBottom, "Frequency (Hz)") self.gui.specPlot.setAxisTitle(self.gui.specPlot.yLeft, "Time (sec)") # Set up FFT size combo box self.fftsizes = ["128", "256", "512", "1024", "2048", "4096", "8192", "16384", "32768"] self.gui.psdFFTComboBox.addItems(self.fftsizes) self.gui.specFFTComboBox.addItems(self.fftsizes) pos = self.gui.psdFFTComboBox.findText(Qt.QString("%1").arg(self.psdfftsize)) self.gui.psdFFTComboBox.setCurrentIndex(pos) pos = self.gui.specFFTComboBox.findText(Qt.QString("%1").arg(self.specfftsize)) self.gui.specFFTComboBox.setCurrentIndex(pos) self.connect(self.gui.psdFFTComboBox, Qt.SIGNAL("activated (const QString&)"), self.psdFFTComboBoxEdit) self.connect(self.gui.specFFTComboBox, Qt.SIGNAL("activated (const QString&)"), self.specFFTComboBoxEdit) # Set up color scheme box self.color_modes = {"Black on White" : self.color_black_on_white, "White on Black" : self.color_white_on_black, "Blue on Black" : self.color_blue_on_black, "Green on Black" : self.color_green_on_black} self.gui.colorComboBox.addItems(self.color_modes.keys()) pos = self.gui.colorComboBox.findText("Blue on Black") self.gui.colorComboBox.setCurrentIndex(pos) self.connect(self.gui.colorComboBox, Qt.SIGNAL("activated (const QString&)"), self.colorComboBoxEdit) # Set up line style combo box self.line_styles = {"None" : Qwt.QwtSymbol.NoSymbol, "Circle" : Qwt.QwtSymbol.Ellipse, "Diamond" : Qwt.QwtSymbol.Rect, "Triangle" : Qwt.QwtSymbol.Triangle} self.gui.lineStyleComboBox.addItems(self.line_styles.keys()) pos = self.gui.lineStyleComboBox.findText("None") self.gui.lineStyleComboBox.setCurrentIndex(pos) self.connect(self.gui.lineStyleComboBox, Qt.SIGNAL("activated (const QString&)"), self.lineStyleComboBoxEdit) # Create zoom functionality for the plots self.timeZoomer = Qwt.QwtPlotZoomer(self.gui.timePlot.xBottom, self.gui.timePlot.yLeft, Qwt.QwtPicker.PointSelection, Qwt.QwtPicker.AlwaysOn, self.gui.timePlot.canvas()) self.freqZoomer = Qwt.QwtPlotZoomer(self.gui.freqPlot.xBottom, self.gui.freqPlot.yLeft, Qwt.QwtPicker.PointSelection, Qwt.QwtPicker.AlwaysOn, self.gui.freqPlot.canvas()) self.specZoomer = Qwt.QwtPlotZoomer(self.gui.specPlot.xBottom, self.gui.specPlot.yLeft, Qwt.QwtPicker.PointSelection, Qwt.QwtPicker.AlwaysOn, self.gui.specPlot.canvas()) # Set up action when tab is changed self.connect(self.gui.tabGroup, Qt.SIGNAL("currentChanged (int)"), self.tabChanged) # Add a legend to the Time plot legend_real = Qwt.QwtLegend() self.gui.timePlot.insertLegend(legend_real) # Set up slider self.gui.plotHBar.setSingleStep(1) self.gui.plotHBar.setPageStep(self.block_length) self.gui.plotHBar.setMinimum(0) self.gui.plotHBar.setMaximum(self.block_length) self.connect(self.gui.plotHBar, Qt.SIGNAL("valueChanged(int)"), self.sliderMoved) # Connect Open action to Open Dialog box self.connect(self.gui.action_open, Qt.SIGNAL("activated()"), self.open_file) # Connect Reload action to reload the file self.connect(self.gui.action_reload, Qt.SIGNAL("activated()"), self.reload_file) self.gui.action_reload.setShortcut(QtGui.QApplication.translate("MainWindow", "Ctrl+R", None, QtGui.QApplication.UnicodeUTF8)) # Set up file position boxes to update current figure self.connect(self.gui.filePosStartLineEdit, Qt.SIGNAL("editingFinished()"), self.file_position_changed) self.connect(self.gui.filePosStopLineEdit, Qt.SIGNAL("editingFinished()"), self.file_position_changed) self.connect(self.gui.filePosLengthLineEdit, Qt.SIGNAL("editingFinished()"), self.file_length_changed) self.connect(self.gui.fileTimeStartLineEdit, Qt.SIGNAL("editingFinished()"), self.file_time_changed) self.connect(self.gui.fileTimeStopLineEdit, Qt.SIGNAL("editingFinished()"), self.file_time_changed) self.connect(self.gui.fileTimeLengthLineEdit, Qt.SIGNAL("editingFinished()"), self.file_time_length_changed) stylestr = str(self.gui.lineStyleComboBox.currentText().toAscii()) style = self.line_styles[stylestr] self.rcurve = Qwt.QwtPlotCurve("Real") self.icurve = Qwt.QwtPlotCurve("Imaginary") self.rsym = Qwt.QwtSymbol() self.rsym.setStyle(style) self.rsym.setSize(10) self.isym = Qwt.QwtSymbol() self.isym.setStyle(style) self.isym.setSize(10) self.rcurve.setSymbol(self.rsym) self.icurve.setSymbol(self.isym) self.icurve.attach(self.gui.timePlot) self.rcurve.attach(self.gui.timePlot) self.psdcurve = Qwt.QwtPlotCurve("PSD") self.psdcurve.attach(self.gui.freqPlot) # Set up specTab plot as a spectrogram self.specdata = SpectrogramData(range(0, 10), range(0, 10)) colorMap = Qwt.QwtLinearColorMap(Qt.Qt.darkCyan, Qt.Qt.red) colorMap.addColorStop(0.1, Qt.Qt.cyan) colorMap.addColorStop(0.6, Qt.Qt.green) colorMap.addColorStop(0.95, Qt.Qt.yellow) self.spec = Qwt.QwtPlotSpectrogram() self.spec.setColorMap(colorMap) self.spec.attach(self.gui.specPlot) self.spec.setDisplayMode(Qwt.QwtPlotSpectrogram.ImageMode, True) self.spec.setData(self.specdata) self.rightAxis = self.gui.specPlot.axisWidget(Qwt.QwtPlot.yRight) self.rightAxis.setTitle("Magnitude (dBm)") self.rightAxis.setColorBarEnabled(True) self.rightAxis.setColorMap(self.spec.data().range(), self.spec.colorMap()) self.gui.specPlot.enableAxis(Qwt.QwtPlot.yRight) # Set up initial color scheme self.color_modes["Blue on Black"]() # When line width spin box changes, update the pen size self.connect(self.gui.lineWidthSpinBox, Qt.SIGNAL("valueChanged(int)"), self.change_pen_width) self.gui.lineWidthSpinBox.setRange(1, 10) # When style size spin box changes, update the pen size self.connect(self.gui.styleSizeSpinBox, Qt.SIGNAL("valueChanged(int)"), self.change_style_size) self.gui.styleSizeSpinBox.setRange(1, 20) self.gui.styleSizeSpinBox.setValue(5) # Connect a signal for when the sample rate changes self.set_sample_rate(self.sample_rate) self.connect(self.gui.sampleRateLineEdit, Qt.SIGNAL("editingFinished()"), self.sample_rate_changed) if(filename is not None): self.initialize(filename) self.show()
def __init__(self, module, *args): ''' Constructor @param module: parent module ''' apply(Qt.QDialog.__init__, (self, ) + args) self.setupUi(self) self.module = module self.params = None # last received parameter block self.data = None # last received data block # create table view grid (10x16 eeg electrodes + 1 row for ground electrode) cc = 10 rc = 16 self.tableWidgetValues.setColumnCount(cc) self.tableWidgetValues.setRowCount(rc + 1) self.tableWidgetValues.horizontalHeader().setResizeMode( Qt.QHeaderView.Stretch) self.tableWidgetValues.horizontalHeader().setDefaultAlignment( Qt.Qt.Alignment(Qt.Qt.AlignCenter)) self.tableWidgetValues.verticalHeader().setResizeMode( Qt.QHeaderView.Stretch) self.tableWidgetValues.verticalHeader().setDefaultAlignment( Qt.Qt.Alignment(Qt.Qt.AlignCenter)) # add ground electrode row self.tableWidgetValues.setSpan(rc, 0, 1, cc) # row headers rheader = Qt.QStringList() for r in xrange(rc): rheader.append("%d - %d" % (r * cc + 1, r * cc + cc)) rheader.append("GND") self.tableWidgetValues.setVerticalHeaderLabels(rheader) # create cell items fnt = Qt.QFont() fnt.setPointSize(8) for r in xrange(rc): for c in xrange(cc): item = Qt.QTableWidgetItem() item.setTextAlignment(Qt.Qt.AlignCenter) item.setFont(fnt) self.tableWidgetValues.setItem(r, c, item) # GND electrode cell item = Qt.QTableWidgetItem() item.setTextAlignment(Qt.Qt.AlignCenter) item.setFont(fnt) item.setText("GND") self.tableWidgetValues.setItem(rc, 0, item) self.defaultColor = item.backgroundColor() # set range list self.comboBoxRange.clear() self.comboBoxRange.addItem("15") self.comboBoxRange.addItem("50") self.comboBoxRange.addItem("100") self.comboBoxRange.addItem("500") # set validators validator = Qt.QIntValidator(self) validator.setBottom(15) validator.setTop(500) self.comboBoxRange.setValidator(validator) self.comboBoxRange.setEditText(str(self.module.range_max)) # setup color scale self.linearscale = False self.scale_engine = Qwt.QwtLinearScaleEngine() self.scale_interval = Qwt.QwtDoubleInterval(0, self.module.range_max) self.scale_map = Qwt.QwtLinearColorMap(Qt.Qt.green, Qt.Qt.red) if self.linearscale: self.scale_map.addColorStop(0.45, Qt.Qt.yellow) self.scale_map.addColorStop(0.55, Qt.Qt.yellow) self.scale_map.setMode(Qwt.QwtLinearColorMap.ScaledColors) else: self.scale_map.addColorStop(0.33, Qt.Qt.yellow) self.scale_map.addColorStop(0.66, Qt.Qt.red) self.scale_map.setMode(Qwt.QwtLinearColorMap.FixedColors) self.ScaleWidget.setColorMap(self.scale_interval, self.scale_map) self.ScaleWidget.setColorBarEnabled(True) self.ScaleWidget.setColorBarWidth(30) self.ScaleWidget.setBorderDist(10, 10) # set default values self.setColorRange(0, self.module.range_max) self.checkBoxValues.setChecked(self.module.show_values) # actions self.connect(self.comboBoxRange, Qt.SIGNAL("editTextChanged(QString)"), self._rangeChanged) self.connect(self.checkBoxValues, Qt.SIGNAL("stateChanged(int)"), self._showvalues_changed) self.connect(self.module, Qt.SIGNAL('update(PyQt_PyObject)'), self._updateValues)
def __init__(self, grblock, *args): Qwt.QwtPlot.__init__(self, *args) self.grblock = grblock self.scatter = np.zeros((self.grblock.nt, self.grblock.ntau)) # set plot title self.setTitle('Scattering Function') # set plot layout self.plotLayout().setMargin(0) self.plotLayout().setCanvasMargin(0) self.plotLayout().setAlignCanvasToScales(True) # set legend legend = Qwt.QwtLegend() legend.setItemMode(Qwt.QwtLegend.ClickableItem) self.insertLegend(legend, Qwt.QwtPlot.RightLegend) # set axis titles self.setAxisTitle(Qwt.QwtPlot.xBottom, 'Delay (s)') self.setAxisTitle(Qwt.QwtPlot.yLeft, 'Doppler Spectrum (Hz)') # scale x-axis t_scale = time_scale(self.grblock.t_symbol) self.setAxisScaleDraw(Qwt.QwtPlot.xBottom, t_scale) # scale y-axis f_scale = freq_scale(self.grblock.prf, self.grblock.nt) self.setAxisScaleDraw(Qwt.QwtPlot.yLeft, f_scale) # create a QwtRasterData instance to store the numpy array # produced by the GNU Radio Python sink block self.scatter_data = ScatterData(self.scatter) # create a QwtPlotSpectrogram instance to plot the QwtRasterData self.plot_scatter = Qwt.QwtPlotSpectrogram() # create a greyscale colormap colorMap = Qwt.QwtLinearColorMap(Qt.Qt.black, Qt.Qt.white) self.plot_scatter.setColorMap(colorMap) # attach and pass the data self.plot_scatter.attach(self) self.plot_scatter.setData(self.scatter_data) # replot self.replot() # zoomer self.zoomer = Qwt.QwtPlotZoomer(Qwt.QwtPlot.xBottom, Qwt.QwtPlot.yLeft, Qwt.QwtPicker.DragSelection, Qwt.QwtPicker.AlwaysOff, self.canvas()) self.zoomer.setRubberBandPen(Qt.QPen(Qt.Qt.green)) # picker showing the coordinates at the mouse pointer self.picker = QwtPlotPicker(self.grblock.t_symbol, self.grblock.nt, self.grblock.prf, Qwt.QwtPlot.xBottom, Qwt.QwtPlot.yLeft, Qwt.QwtPicker.PointSelection, Qwt.QwtPlotPicker.CrossRubberBand, Qwt.QwtPicker.AlwaysOn, self.canvas()) self.picker.setTrackerPen(Qt.QPen(Qt.Qt.cyan))
def create_main_frame(self): # Plot and ampere # self.ampere_plot, self.curve = self.create_plot( xaxis=(0, 10, 1), yaxis=(0, 250, 40), yaxis_label='Current (mA)', color='blue') self.ampere = self.create_scale((0, 200, 180)) ampere_l = QLabel('Average') ampere_layout = QHBoxLayout() ampere_layout.addWidget(ampere_l) ampere_layout.addWidget(self.ampere) ampere_layout.setSpacing(5) o = Qt.Vertical s = Qwt.QwtThermo.RightScale colorMap = Qwt.QwtLinearColorMap(Qt.green, Qt.red) #colorMap.addColorStop(0.2, Qt.Qt.blue) #colorMap.addColorStop(0.4, Qt.Qt.green) self.voltage_pack = self.create_scale( (self.num_cells * 3.7, self.num_cells * 4.2, self.num_cells * 3.8), 40, o, alarm=False) self.cellvoltages = [ self.create_scale((3.7, 4.2, 3.8), 6, o, s, alarm=False) for x in range(self.num_cells) ] pack_voltage = QVBoxLayout() voltage_l = QLabel('Pack Voltage') pack_voltage.addWidget(voltage_l) pack_voltage.addWidget(self.voltage_pack) voltages_layout = QHBoxLayout() voltages_layout.addLayout(pack_voltage) for x in range(self.num_cells): layout = QVBoxLayout() layout.addWidget(QLabel('Cell_%d' % (x + 1))) layout.addWidget(self.cellvoltages[x]) layout.setSpacing(5) voltages_layout.addLayout(layout) self.updatespeed_knob = self.create_knob() self.connect(self.updatespeed_knob, SIGNAL('valueChanged(double)'), self.on_knob_change) self.knob_l = QLabel('Update speed = %s (Hz)' % self.updatespeed_knob.value()) self.knob_l.setAlignment(Qt.AlignTop | Qt.AlignHCenter) knob_layout = QVBoxLayout() knob_layout.addWidget(self.updatespeed_knob) knob_layout.addWidget(self.knob_l) ampere_plot_layout = QVBoxLayout() ampere_plot_layout.addWidget(self.ampere_plot) ampere_plot_layout.addLayout(ampere_layout) plots_layout = QHBoxLayout() plots_layout.addLayout(ampere_plot_layout) plots_layout.addStretch(1) plot_groupbox = QGroupBox('Current Monitor') plot_groupbox.setLayout(plots_layout) voltage_groupbox = QGroupBox('Voltage Monitor') voltage_groupbox.setLayout(voltages_layout) # Main frame and layout # self.main_frame = QWidget() main_layout = QVBoxLayout() sub_layout = QHBoxLayout() sub_layout.addWidget(plot_groupbox) sub_layout.addWidget(voltage_groupbox) main_layout.addLayout(sub_layout) main_layout.addLayout(knob_layout) main_layout.addStretch(1) self.main_frame.setLayout(main_layout) self.setCentralWidget(self.main_frame) self.set_actions_enable_state()