def paintEvent(self, event): with XPainter(self) as painter: painter.fillRect(event.rect(), QtGui.QColor('lightGray')) edit = self.codeEditor() block = edit.firstVisibleBlock() blockNumber = block.blockNumber() top = edit.blockBoundingGeometry(block).translated( edit.contentOffset()).top() bottom = top + edit.blockBoundingRect(block).height() textHeight = edit.fontMetrics().height() painter.setFont(self.font()) painter.setPen(QtGui.QColor('black')) while block.isValid() and top <= event.rect().bottom(): if block.isVisible() and bottom >= event.rect().top(): painter.drawText(0, top, self.width() - 6, textHeight, QtCore.Qt.AlignRight, str(blockNumber + 1)) block = block.next() top = bottom bottom = top + edit.blockBoundingRect(block).height() blockNumber += 1
def __init__(self, parent=None): super(XOverlayWizard, self).__init__(parent) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) # define custom properties self._fixedPageSize = QtCore.QSize() self._minimumPageSize = QtCore.QSize(0, 0) self._maximumPageSize = QtCore.QSize(10000, 10000) self._currentId = -1 self._startId = -1 self._pages = OrderedDict() self._buttons = {} self._fields = {} self._navigation = [] self._animationSpeed = 350 # create the buttons self._buttons[self.WizardButton.HelpButton] = QtGui.QPushButton( self.tr('Help'), self) self._buttons[self.WizardButton.BackButton] = QtGui.QPushButton( self.tr('Back'), self) self._buttons[self.WizardButton.NextButton] = QtGui.QPushButton( self.tr('Next'), self) self._buttons[self.WizardButton.CommitButton] = QtGui.QPushButton( self.tr('Commit'), self) self._buttons[self.WizardButton.FinishButton] = QtGui.QPushButton( self.tr('Finish'), self) self._buttons[self.WizardButton.CancelButton] = QtGui.QPushButton( self.tr('Cancel'), self) self._buttons[self.WizardButton.RetryButton] = QtGui.QPushButton( self.tr('Retry'), self) # don't show any buttons by default pal = self.palette() for which, btn in self._buttons.items(): pal.setColor(pal.Active, pal.Button, QtGui.QColor(self.WizardButtonColors[which])) pal.setColor(pal.Active, pal.ButtonText, QtGui.QColor('white')) pal.setColor(pal.Inactive, pal.Button, QtGui.QColor(self.WizardButtonColors[which])) pal.setColor(pal.Inactive, pal.ButtonText, QtGui.QColor('white')) btn.setPalette(pal) btn.setFixedSize(QtCore.QSize(120, 30)) btn.hide() # create connections self._buttons[self.WizardButton.HelpButton].clicked.connect( self.helpRequested) self._buttons[self.WizardButton.BackButton].clicked.connect(self.back) self._buttons[self.WizardButton.NextButton].clicked.connect(self.next) self._buttons[self.WizardButton.CommitButton].clicked.connect( self.commit) self._buttons[self.WizardButton.FinishButton].clicked.connect( self.accept) self._buttons[self.WizardButton.CancelButton].clicked.connect( self.reject) self._buttons[self.WizardButton.RetryButton].clicked.connect( self.retry)
def updateUi(self): if self.uiRecordBTN.isChecked(): ico = resources.find('img/debug/break.png') clr = QtGui.QColor('red') self.uiRecordBTN.blink(True) else: ico = resources.find('img/debug/continue.png') clr = QtGui.QColor('blue') self.uiRecordBTN.blink(False) self.uiRecordBTN.setIcon(QtGui.QIcon(ico)) palette = self.uiRecordBTN.palette() palette.setColor(palette.Shadow, clr) self.uiRecordBTN.setPalette(palette)
def __init__(self, parent=None): super(XOverlayWidget, self).__init__(parent) # define custom properties self._centralWidget = None self._result = None self._closable = True self._closeAlignment = QtCore.Qt.AlignTop | QtCore.Qt.AlignRight self._closeButton = XToolButton(self) self._closeButton.setShadowed(True) self._closeButton.setIcon( QtGui.QIcon(resources.find('img/overlay/close.png'))) self._closeButton.setIconSize(QtCore.QSize(24, 24)) self._closeButton.setToolTip('Close') # create the coloring for the overlay palette = self.palette() clr = QtGui.QColor('#222222') clr.setAlpha(210) palette.setColor(palette.Window, clr) self.setPalette(palette) self.setAutoFillBackground(True) # listen to the parents event filter parent.installEventFilter(self) # initialize the widget self.hide() self.move(0, 0) self.resize(parent.size()) self._closeButton.clicked.connect(self.reject)
def __init__(self, parent=None): super(XOverlayWizardPage, self).__init__(parent) self.setFrameShape(QtGui.QFrame.Box) # define custom properties self._commitPage = False self._finalPage = False self._retryEnabled = False self._nextId = None # create the title information font = self.font() font.setBold(True) base_size = font.pointSize() font.setPointSize(base_size + 4) # set the palette coloring pal = self.palette() pal.setColor(pal.WindowText, QtGui.QColor('white')) self.setPalette(pal) # create the title labels self._titleLabel = QtGui.QLabel('', self) self._titleLabel.setFont(font) self._titleLabel.setPalette(pal) font.setPointSize(base_size + 2) self._subTitleLabel = QtGui.QLabel('', self) self._subTitleLabel.setPalette(pal) self.adjustMargins()
def __init__(self, parent, record): super(XLogRecordItem, self).__init__(parent) # set default properties self.setFixedHeight(22) created = datetime.datetime.fromtimestamp(record.created) self.setData(0, QtCore.Qt.DisplayRole, wrapVariant(record.levelname)) self.setData(1, QtCore.Qt.DisplayRole, wrapVariant(record.levelno)) self.setData(2, QtCore.Qt.DisplayRole, wrapVariant(record.name)) self.setData(3, QtCore.Qt.DisplayRole, wrapVariant(str(created))) self.setData(4, QtCore.Qt.DisplayRole, wrapVariant(record.message)) self.setData( 5, QtCore.Qt.DisplayRole, wrapVariant('% 10.4f' % (record.relativeCreated / 1000.0))) self.setData(6, QtCore.Qt.DisplayRole, wrapVariant(record.filename)) self.setData(7, QtCore.Qt.DisplayRole, wrapVariant(record.module)) self.setData(8, QtCore.Qt.DisplayRole, wrapVariant(record.funcName)) self.setData(9, QtCore.Qt.DisplayRole, wrapVariant(record.lineno)) self.setData(10, QtCore.Qt.DisplayRole, wrapVariant(record.pathname)) self.setData(11, QtCore.Qt.DisplayRole, wrapVariant(record.process)) self.setData(12, QtCore.Qt.DisplayRole, wrapVariant(record.processName)) self.setData(13, QtCore.Qt.DisplayRole, wrapVariant(record.thread)) self.setData(14, QtCore.Qt.DisplayRole, wrapVariant(record.threadName)) clr = XLogRecordItem.Colors.get(record.levelno) if clr: for i in range(self.columnCount()): self.setForeground(i, QtGui.QColor(clr)) # create custom properties self._record = record
def updateUi(self): if self.logger() == 'root': log = logging.getLogger() else: log = logging.getLogger(self.logger()) level = log.level if self.treeWidget().loggerWidget().hasLogger(self.logger()): checked = QtCore.Qt.Checked fg = QtGui.QColor('black') else: checked = QtCore.Qt.Unchecked fg = QtGui.QColor('gray') self.setCheckState(0, checked) self.setForeground(0, fg) self.setForeground(1, fg) text = XLoggerTreeWidget.LoggingMap.get(level, ('', ''))[0] self.setText(1, projex.text.pretty(text))
def foreground(self): """ Returns the foreground color for this group item. :return <QtGui.QColor> """ widget = self.widget() if widget: palette = widget.palette() return palette.color(palette.WindowText) else: return QtGui.QColor()
def highlightCurrentLine(self): extra = [] if not self.isReadOnly(): lineColor = QtGui.QColor('yellow').lighter(160) selection = QtGui.QTextEdit.ExtraSelection() selection.format.setBackground(lineColor) selection.format.setProperty(QtGui.QTextFormat.FullWidthSelection, True) selection.cursor = self.textCursor() selection.cursor.clearSelection() extra.append(selection) self.setExtraSelections(extra)
def __init__(self, *args): super(XPalette, self).__init__(*args) # initialize the custom color roles dc = QtGui.QColor() roles = self.CustomRoles self._custom = { QtGui.QPalette.Active: {getattr(self, k): dc for k in roles}, QtGui.QPalette.Inactive: {getattr(self, k): dc for k in roles}, QtGui.QPalette.Disabled: {getattr(self, k): dc for k in roles}, }
def setCentralWidget(self, widget): """ Sets the central widget for this overlay to the inputed widget. :param widget | <QtGui.QWidget> """ self._centralWidget = widget if widget is not None: widget.setParent(self) widget.installEventFilter(self) # create the drop shadow effect effect = QtGui.QGraphicsDropShadowEffect(self) effect.setColor(QtGui.QColor('black')) effect.setBlurRadius(80) effect.setOffset(0, 0) widget.setGraphicsEffect(effect)
def __init__(self, parent=None): super(XLockButton, self).__init__(parent) # define custom properties self._lockIcon = None self._unlockIcon = None # set properties palette = self.palette() palette.setColor(palette.Shadow, QtGui.QColor('orange')) self.setPalette(palette) self.setLockIcon(resources.find('img/ui/lock.png')) self.setUnlockIcon(resources.find('img/ui/unlock.png')) self.setCheckable(True) self.setChecked(False) self.setShadowed(True) # update the icon based on the lock state self.toggled.connect(self.updateState)
def setPage(self, pageId, page): """ Sets the page and id for the given page vs. auto-constructing it. This will allow the developer to create a custom order for IDs. :param pageId | <int> page | <projexui.widgets.xoverlaywizard.XOverlayWizardPage> """ page.setParent(self) # create the drop shadow effect effect = QtGui.QGraphicsDropShadowEffect(page) effect.setColor(QtGui.QColor('black')) effect.setBlurRadius(50) effect.setOffset(0, 0) page.setGraphicsEffect(effect) self._pages[pageId] = page if self._startId == -1: self._startId = pageId
def darkScheme(): out = XLoggerColorSet() out.setColor('Standard', QtGui.QColor('white')) out.setColor('Debug', QtGui.QColor(220, 220, 220)) out.setColor('Info', QtGui.QColor('cyan')) out.setColor('Success', QtGui.QColor('green')) out.setColor('Warning', QtGui.QColor('yellow')) out.setColor('Error', QtGui.QColor('red')) out.setColor('Critical', QtGui.QColor('red')) out.setColor('Background', QtGui.QColor(40, 40, 40)) out.setColor('String', QtGui.QColor('orange')) out.setColor('Number', QtGui.QColor('red')) out.setColor('Comment', QtGui.QColor(140, 255, 140)) out.setColor('Keyword', QtGui.QColor('cyan')) return out
def __init__( self, *args, **defaults ): super(XLoggerColorSet, self).__init__(*args, **defaults) self.setColorGroups(['Default']) self.setColor('Standard', QtGui.QColor('black')) self.setColor('Debug', QtGui.QColor('gray')) self.setColor('Info', QtGui.QColor('blue')) self.setColor('Success', QtGui.QColor('darkGreen')) self.setColor('Warning', QtGui.QColor('orange').darker(150)) self.setColor('Error', QtGui.QColor('darkRed')) self.setColor('Critical', QtGui.QColor('darkRed')) self.setColor('Background', QtGui.QColor(250, 250, 250)) self.setColor('String', QtGui.QColor('darkRed')) self.setColor('Number', QtGui.QColor('orange').darker(150)) self.setColor('Comment', QtGui.QColor('green')) self.setColor('Keyword', QtGui.QColor('blue'))
def __init__(self, *args): super(XNodePalette, self).__init__(*args) try: other = args[0] if isinstance(args[0], XNodePalette) else None except IndexError: other = None if other: grid_bg = other.color(other.GridBackground) grid_fg = other.color(other.GridForeground) grid_fg_alt = other.color(other.GridAlternateForeground) grid_ctr = other.color(other.GridCenterline) node_bg = other.color(other.NodeBackground) node_alt = other.color(other.NodeAlternateBackground) node_fg = other.color(other.NodeForeground) node_bg_d = other.color(other.Disabled, other.NodeBackground) node_alt_d = other.color(other.Disabled, other.NodeAlternateBackground) node_fg_d = other.color(other.Disabled, other.NodeForeground) node_bdr = other.color(other.NodeBorder) node_bdr_d = other.color(other.Disabled, other.NodeBorder) node_hspt = other.color(other.NodeHotspot) node_hlt = other.color(other.NodeHighlight) con = other.color(other.Connection) con_d = other.color(other.Disabled, other.Connection) con_hlt = other.color(other.ConnectionHighlight) else: grid_bg = QtGui.QColor(200, 200, 200) grid_fg = QtGui.QColor(180, 180, 180) grid_fg_alt = QtGui.QColor(190, 190, 190) grid_ctr = QtGui.QColor(160, 160, 160) node_bg = QtGui.QColor(255, 255, 255) node_alt = QtGui.QColor(245, 245, 245) node_fg = QtGui.QColor(90, 90, 90) node_bg_d = QtGui.QColor(220, 220, 220) node_alt_d = QtGui.QColor(210, 210, 210) node_fg_d = QtGui.QColor(160, 160, 160) node_bdr = QtGui.QColor(90, 90, 90) node_bdr_d = QtGui.QColor(160, 160, 160) node_hspt = QtGui.QColor(255, 255, 255) node_hlt = QtGui.QColor(90, 90, 200) con = QtGui.QColor(90, 90, 90) con_d = QtGui.QColor(180, 180, 180) con_hlt = QtGui.QColor(90, 90, 200) # setup grid coloring self.setColor(self.GridBackground, grid_bg) self.setColor(self.GridForeground, grid_fg) self.setColor(self.GridAlternateForeground, grid_fg_alt) self.setColor(self.GridCenterline, grid_ctr) # setup node coloring self.setColor(self.NodeBackground, node_bg) self.setColor(self.NodeAlternateBackground, node_alt) self.setColor(self.NodeForeground, node_fg) self.setColor(self.NodeBorder, node_bdr) self.setColor(self.NodeHighlight, node_hlt) self.setColor(self.NodeHotspot, node_hspt) self.setColor(self.Disabled, self.NodeBackground, node_bg_d) self.setColor(self.Disabled, self.NodeAlternateBackground, node_alt_d) self.setColor(self.Disabled, self.NodeForeground, node_fg_d) self.setColor(self.Disabled, self.NodeBorder, node_bdr_d) self.setColor(self.Connection, con) self.setColor(self.Disabled, self.Connection, con_d) self.setColor(self.ConnectionHighlight, con_hlt)