def __init__(self, parent, filename='', lineno=0): super(XScintillaEdit, self).__init__(parent) # create custom properties self._filename = '' self._dirty = False self._marginsFont = QFont() self._saveOnClose = True self._colorSet = None self._language = None # define markers breakpoint_ico = projexui.resources.find('img/debug/break.png') debug_ico = projexui.resources.find('img/debug/current.png') self._breakpointMarker = self.markerDefine(QPixmap(breakpoint_ico)) self._currentDebugMarker = self.markerDefine(QPixmap(debug_ico)) # set one time properties self.setFolding(QsciScintilla.BoxedTreeFoldStyle) self.setBraceMatching(QsciScintilla.SloppyBraceMatch) self.setContextMenuPolicy(Qt.NoContextMenu) # load the inputed filename self.initOptions(XScintillaEditOptions()) self.load(filename, lineno)
def __init__( self, parent, plugin ): super(PluginWidget, self).__init__(parent) self._icon = QLabel(self) pixmap = QPixmap(plugin.iconFile()) if pixmap.isNull(): pixmap = QPixmap(projexui.resources.find('img/plugin_48.png')) self._icon.setPixmap(pixmap) self._icon.setMinimumWidth(48) self._icon.setMinimumHeight(48) self._icon.setAlignment(Qt.AlignCenter) self._title = QLabel(plugin.title(), self) self._title.setAlignment(Qt.AlignCenter) font = self.font() font.setPointSize(7) self._title.setFont(font) vbox = QVBoxLayout() vbox.addStretch() vbox.addWidget(self._icon) vbox.addWidget(self._title) vbox.addStretch() self.setLayout(vbox) self._plugin = plugin
def setLogo(self, logo): """ Sets the logo image for this dialog :param logo | <QPixmap> || <str> """ if (isinstance(logo, basestring)): logo = QPixmap(logo) self.uiLogoLBL.setHidden(logo.isNull()) self.uiLogoLBL.setPixmap(logo)
def setLogo( self, logo ): """ Sets the logo image for this dialog :param logo | <QPixmap> || <str> """ if ( isinstance(logo, basestring) ): logo = QPixmap(logo) self.uiLogoLBL.setHidden(logo.isNull()) self.uiLogoLBL.setPixmap(logo)
def __init__(self, parent=None): super(XRatingSlider, self).__init__(parent) # define custom properties self._emptyPixmap = QPixmap(resources.find('img/star_gray.png')) self._fullPixmap = QPixmap(resources.find('img/star.png')) self._alignment = Qt.AlignCenter self._pixmapSize = QSize(16, 16) # set default properties self.setOrientation(Qt.Horizontal) self.setMinimum(0) self.setMaximum(10) self.setPixmapSize(QSize(16, 16))
def save(self): """ Saves the snapshot based on the current region. """ # close down the snapshot widget if self.hideWindow(): self.hideWindow().hide() self.hide() QApplication.processEvents() time.sleep(1) # create the pixmap to save wid = QApplication.desktop().winId() if not self._region.isNull(): x = self._region.x() y = self._region.y() w = self._region.width() h = self._region.height() else: x = self.x() y = self.y() w = self.width() h = self.height() pixmap = QPixmap.grabWindow(wid, x, y, w, h) pixmap.save(self.filepath()) self.close() self.deleteLater() if self.hideWindow(): self.hideWindow().show()
def generatePixmap(color, style=Style.Plain, size=None): """ Generates a new pixmap for the inputed color and style. If no size is provided, then the default 32x32 will be used. :return <QPixmap> """ if size is None: size = QSize(32, 32) pixmap = QPixmap(size) # create a plain pixmap if style == XColorIcon.Style.Plain: pixmap.fill(color) return pixmap
def mousePressEvent(self, event): btn = event.button() mid = btn == Qt.MidButton lft = btn == Qt.LeftButton shft = event.modifiers() == Qt.ShiftModifier if self.windowFlags() & Qt.Dialog and \ (mid or (lft and shft)): pixmap = QPixmap.grabWidget(self) drag = QDrag(self) data = QMimeData() data.setData('x-application/xview/floating_view',\ QByteArray(self.objectName())) drag.setMimeData(data) drag.setPixmap(pixmap) self.hide() drag.exec_() self.show() else: super(XView, self).mousePressEvent(event)
def paintEvent(self, event): """ Paints this combobox based on whether or not it is visible. :param event | <QPaintEvent> """ if not self.autoRaise() or (self._hovered and self.isEnabled()): super(XComboBox, self).paintEvent(event) text = QComboBox.currentText(self) if not text and self._hint and not self.lineEdit(): text = self._hint palette = self.palette() with XPainter(self) as painter: painter.setPen( palette.color(palette.Disabled, palette.Text)) painter.drawText(5, 0, self.width(), self.height(), Qt.AlignLeft | Qt.AlignVCenter, self.currentText()) else: palette = self.palette() with XPainter(self) as painter: text = QComboBox.currentText(self) if not text: text = self.hint() painter.setPen( palette.color(palette.Disabled, palette.WindowText)) painter.drawText(5, 0, self.width(), self.height(), Qt.AlignLeft | Qt.AlignVCenter, text) x = self.width() - 15 y = 4 pixmap = QPixmap( resources.find('img/treeview/triangle_down.png')) painter.drawPixmap(x, y, pixmap)
def rebuildTiles(self): # create the foreground pixmap gantt = self.ganttWidget() header = gantt.treeWidget().header() width = self.sceneRect().width() height = header.height() # create the main color palette = gantt.palette() color = palette.color(palette.Button) textColor = palette.color(palette.ButtonText) borderColor = color.darker(140) text_align = Qt.AlignBottom | Qt.AlignHCenter # create the gradient gradient = QLinearGradient() gradient.setStart(0, 0) gradient.setFinalStop(0, height) gradient.setColorAt(0, color) gradient.setColorAt(1, color.darker(120)) # generate the tiles tiles = [] painters = [] for rect, label in self._topLabels: tile_rect = QRectF(rect.x(), 0, rect.width(), height) pixmap = QPixmap(rect.width(), height) with XPainter(pixmap) as painter: painter.setBrush(QBrush(gradient)) painter.drawRect(tile_rect) rx = 0 ry = 0 rw = rect.width() rh = rect.height() painter.setPen(borderColor) painter.drawRect(rx, ry, rw, rh) painter.setPen(textColor) painter.drawText(rx, ry, rw, rh - 2, text_align, label) tiles.append((tile_rect, pixmap)) painters.append((tile_rect, pixmap, painter)) # add bottom labels for rect, label in self._labels: for tile_rect, tile, painter in painters: if tile_rect.x() <= rect.x() and \ rect.right() <= tile_rect.right(): rx = rect.x() - tile_rect.x() ry = rect.y() rw = rect.width() rh = rect.height() with painter: painter.setPen(borderColor) painter.drawRect(rx, ry, rw, rh) painter.setPen(textColor) painter.drawText(rx, ry, rw, rh - 2, text_align, label) self._tiles = tiles