def paintCell(self, painter, color_group, column, width, align): try: painter.save() color_group = qt.QColorGroup(color_group) color_group.setColor(qt.QColorGroup.Text, self.brush.color()) color_group.setBrush(qt.QColorGroup.Text, self.brush) qt.QListViewItem.paintCell(self, painter, color_group, column, width, align) finally: painter.restore()
def setEditorBackgroundColor(self, color): #print "SpinBox.setEditorBackgroundColor",color editor = self.editor() editor.setPaletteBackgroundColor(color) spinbox_palette = editor.palette() try: cg = self.colorGroupDict[color.rgb()] except KeyError: cg = qt.QColorGroup(spinbox_palette.disabled()) cg.setColor(cg.Background, color) self.colorGroupDict[color.rgb()] = cg spinbox_palette.setDisabled(cg)
def paintCell(self, painter, color_group, column, width, align): """ Inherited from QCheckListItem, called before this item is drawn on the screen. The qt3 documentation has more information about this method that can be worth reading. """ try: painter.save() f = painter.font() f.setBold(self._font_is_bold) painter.setFont(f) color_group = qt.QColorGroup(color_group) color_group.setColor(qt.QColorGroup.Text, self.brush.color()) color_group.setBrush(qt.QColorGroup.Text, self.brush) color_group.setColor(qt.QColorGroup.Base, self.bg_brush.color()) qt.QCheckListItem.paintCell(self, painter, color_group, column, width, align) finally: painter.restore()
def paintCell(self, p, cg, column, width, align, black=qt.Qt.black, red=qt.Qt.red, green=qt.Qt.darkGreen, blue=qt.Qt.blue): """ paintCell(...) -> add some red/green logic to a cell before painting """ if self.useColor: try: listview = self.listView() pricesize = listview.columnPriceSize[column] current = self.current[pricesize] previous = self.previous[pricesize] except (Exception, ): qt.QListViewItem.paintCell(self, p, cg, column, width, align) return cg = qt.QColorGroup(cg) if previous == 0: color = black elif current > previous: color = green elif current < previous: color = red else: color = blue cg.setColor(qt.QColorGroup.Text, color) qt.QListViewItem.paintCell(self, p, cg, column, width, align)