def updateUI(self): theme = self.m_themeComboBox.itemData( self.m_themeComboBox.currentIndex()) if self.m_charts[0].chart().theme() != theme: for chartView in self.m_charts: chartView.chart().setTheme(theme) pal = self.window().palette() if theme == QChart.ChartThemeLight: pal.setColor(QPalette.Window, QColor(0xf0f0f0)) pal.setColor(QPalette.WindowText, QColor(0x404044)) elif theme == QChart.ChartThemeDark: pal.setColor(QPalette.Window, QColor(0x121218)) pal.setColor(QPalette.WindowText, QColor(0xd6d6d6)) elif theme == QChart.ChartThemeBlueCerulean: pal.setColor(QPalette.Window, QColor(0x40434a)) pal.setColor(QPalette.WindowText, QColor(0xd6d6d6)) elif theme == QChart.ChartThemeBrownSand: pal.setColor(QPalette.Window, QColor(0x9e8965)) pal.setColor(QPalette.WindowText, QColor(0x404044)) elif theme == QChart.ChartThemeBlueNcs: pal.setColor(QPalette.Window, QColor(0x018bba)) pal.setColor(QPalette.WindowText, QColor(0x404044)) elif theme == QChart.ChartThemeHighContrast: pal.setColor(QPalette.Window, QColor(0xffab03)) pal.setColor(QPalette.WindowText, QColor(0x181818)) elif theme == QChart.ChartThemeBlueIcy: pal.setColor(QPalette.Window, QColor(0xcee7f0)) pal.setColor(QPalette.WindowText, QColor(0x404044)) else: pal.setColor(QPalette.Window, QColor(0xf0f0f0)) pal.setColor(QPalette.WindowText, QColor(0x404044)) self.window().setPalette(pal) checked = self.m_antialiasCheckBox.isChecked() for chartView in self.m_charts: chartView.setRenderHint(QPainter.Antialiasing, checked) options = QChart.AnimationOptions( self.m_animatedComboBox.itemData( self.m_animatedComboBox.currentIndex())) if self.m_charts[0].chart().animationOptions() != options: for chartView in self.m_charts: chartView.chart().setAnimationOptions(options) alignment = self.m_legendComboBox.itemData( self.m_legendComboBox.currentIndex()) for chartView in self.m_charts: legend = chartView.chart().legend() if alignment == 0: legend.hide() else: legend.setAlignment(Qt.Alignment(alignment)) legend.show()
def __init__(self, parent = None): super(CombinedValueRangeWidget, self).__init__(parent) self.roiWidgets = [] self.roiLayout = QGridLayout(self) self.setLayout(self.roiLayout) hbox = QHBoxLayout() hbox.addWidget(QLabel("min"),0,Qt.Alignment(Qt.AlignLeft)) hbox.addWidget(QLabel("max"),0,Qt.Alignment(Qt.AlignLeft)) self.roiLayout.addLayout(hbox, 0,1) self.roiLayout.addWidget(QLabel("Export Full Range"), 0, 2) self.roiLayout.addItem(QSpacerItem(0,0,QSizePolicy.Expanding, QSizePolicy.Minimum),0,3) self.roiCheckBoxes = [] self.setFocusPolicy(Qt.TabFocus) self.lastInChain = super(CombinedValueRangeWidget, self).nextInFocusChain()
def __init__(self, parent=None): QAbstractItemModel.__init__(self, parent) self.watchpoints = [] self.header = [ QVariant('Condition'), QVariant('Special'), QVariant('Temporary'), QVariant('Enabled'), QVariant('Ignore Count'), ] self.alignments = [ QVariant(Qt.Alignment(Qt.AlignLeft)), QVariant(Qt.Alignment(Qt.AlignLeft)), QVariant(Qt.Alignment(Qt.AlignHCenter)), QVariant(Qt.Alignment(Qt.AlignHCenter)), QVariant(Qt.Alignment(Qt.AlignRight)), ] return
def __init__(self): self.labelAlignment = \ Qt.Alignment( Qt.AlignBottom | Qt.AlignRight | Qt.AlignAbsolute ) QSplashScreen.__init__(self, None, PixmapCache().getPixmap('splash.png')) self.show() QApplication.flush() return
def __init__(self, parent=None): QAbstractItemModel.__init__(self, parent) self.breakpoints = [] self.header = [ QVariant('File:line'), QVariant('Condition'), QVariant('Temporary'), QVariant('Enabled'), QVariant('Ignore Count'), ] self.alignments = [ QVariant(Qt.Alignment(Qt.AlignLeft)), QVariant(Qt.Alignment(Qt.AlignLeft)), QVariant(Qt.Alignment(Qt.AlignHCenter)), QVariant(Qt.Alignment(Qt.AlignHCenter)), QVariant(Qt.Alignment(Qt.AlignRight)), ] self.__columnCount = len(self.header) return
def boxLayout(orientation, *items, **kw): if orientation == Qt.Horizontal: layout = QHBoxLayout() lineClass = HLine else: layout = QVBoxLayout() lineClass = VLine layout.setMargin(0) layout.setSpacing(0) lastStretch=kw.pop("stretch", False) for item in items: if isinstance(item, (list, tuple)): x, w = item[:2] if item[2:]: alignment, = item[2:] else: alignment = Qt.Alignment(0) else: w = 0 alignment = Qt.Alignment(0) x = item if x == "spacing": layout.addSpacing(w) elif x == "stretch": layout.addStretch(w) elif x == "line": layout.addWidget(lineClass(), w, alignment) elif isinstance(x, QLayout): layout.addLayout(x, w) else: layout.addWidget(x, w, alignment) if lastStretch: layout.addStretch(1) return layout
def addRanges(self, keys, extents): for key, extent in zip(keys, extents): w = ValueRangeWidget(self) w.setFocusPolicy(Qt.TabFocus) w.setDType(numpy.uint32) w.setValues(0,extent) w.setLimits(0,extent) #w.setLabels("min:","max:") self.roiWidgets.append(w) row = self.roiLayout.rowCount() align = Qt.Alignment(Qt.AlignLeft) check = QCheckBox() self.roiCheckBoxes.append(check) check.setChecked(True) check.setFocusPolicy(Qt.ClickFocus) if extent == 1: w.setEnabled(False) self.roiLayout.addWidget(QLabel(key + ": "),row, 0, align) self.roiLayout.addWidget(self.roiWidgets[-1],row, 1, align) self.roiLayout.addWidget(check,row, 2, align) def onChanged(i): val1,val2 = self.roiWidgets[i].getValues() lim1,lim2 = self.roiWidgets[i].getLimits() #limits are stored as ranges if val1==lim1 and val2==lim2: self.roiCheckBoxes[i].setChecked(True) else: self.roiCheckBoxes[i].setChecked(False) def onCheck(i, state): if state == 0: return self.roiWidgets[i].setValues(0,extents[i]) self.roiCheckBoxes[i].setChecked(True) for i, check in enumerate(self.roiCheckBoxes): check.stateChanged.connect(partial(onCheck, i)) self.roiWidgets[i].changedSignal.connect(partial(onChanged, i))
def draw_title(self, painter): self.layout().setContentsMargins( self._border_radius, self._title_height + self._border_radius, self._border_radius, self._border_radius) painter.save() painter.setPen(Qt.NoPen) painter.setBrush(self._color) offset = int(2 * self._border_width / 3) rect = QtCore.QRect(offset, offset, self.width() - offset * 2, self._title_height) painter.drawRect(rect) painter.setPen(self._title_color) painter.setFont(self._title_font) offset = self._border_width * 3 text_rect = QtCore.QRect(offset, 0, self.width() - offset * 2, self._title_height) align = Qt.Alignment(Qt.AlignHCenter | Qt.AlignVCenter) painter.drawText(text_rect, align, self._title_text) painter.restore()
def text_alignment_role_handler(model, row, column): return Qt.Alignment(model.text_alignment(row, column))
def header_text_alignment_role_handler(model, orientation, section): return Qt.Alignment(model.header_text_alignment(orientation, section))