def color_icon(color): pixmap = QPixmap(12, 12) if color is None: color = Color(0, 0, 0, 0) pixmap.fill(get_cached_qcolor(color)) icg = IconImage(image=Image(_tkdata=pixmap.toImage())) return Icon(images=[icg])
def _snapAlertPixmaps(self, index, level): """ Snap the alert pixmaps for the specified tab. Parameters ---------- index : int The index of the tab of interest. level : unicode The alert level for which to snap the pixmaps. """ # Force an internal update of the stylesheet rules self.setProperty(u'alert', level) repolish(self) # Setup the style option for the control opt = QStyleOptionTab() self.initStyleOption(opt, index) opt.rect.moveTo(0, 0) # Snap the normal pixmap opt.state &= ~QStyle.State_Selected normal = QPixmap(opt.rect.size()) normal.fill(Qt.transparent) painter = QStylePainter(normal, self) painter.initFrom(self) painter.drawControl(QStyle.CE_TabBarTab, opt) # Snap the selected pixmap opt.state |= QStyle.State_Selected selected = QPixmap(opt.rect.size()) selected.fill(Qt.transparent) painter = QStylePainter(selected, self) painter.initFrom(self) painter.drawControl(QStyle.CE_TabBarTab, opt) # Reset the internal stylesheet style self.setProperty(u'alert', None) repolish(self) # Update the internal tab data data = self._tab_data[index] data.normal = normal data.selected = selected data.alerted = True # Flip the alert flag so the pixmaps are painted self._has_alerts = True
def _snapAlertPixmaps(self, index, level): """ Snap the alert pixmaps for the specified tab. Parameters ---------- index : int The index of the tab of interest. level : unicode The alert level for which to snap the pixmaps. """ # Force an internal update of the stylesheet rules self.setProperty(u'alert', level) repolish(self) # Setup the style option for the control opt = QStyleOptionTabV3() self.initStyleOption(opt, index) opt.rect.moveTo(0, 0) # Snap the normal pixmap opt.state &= ~QStyle.State_Selected normal = QPixmap(opt.rect.size()) normal.fill(Qt.transparent) painter = QStylePainter(normal, self) painter.initFrom(self) painter.drawControl(QStyle.CE_TabBarTab, opt) # Snap the selected pixmap opt.state |= QStyle.State_Selected selected = QPixmap(opt.rect.size()) selected.fill(Qt.transparent) painter = QStylePainter(selected, self) painter.initFrom(self) painter.drawControl(QStyle.CE_TabBarTab, opt) # Reset the internal stylesheet style self.setProperty(u'alert', None) repolish(self) # Update the internal tab data data = self._tab_data[index] data.normal = normal data.selected = selected data.alerted = True # Flip the alert flag so the pixmaps are painted self._has_alerts = True