def setEdit(self, editWidget, foregroundColor, backGroundColor, borderColor, \ selectionColor, selectionBackGroundColor, opacity): # se i colori sono None allora non vengono alterati # caso particolare per borderColor = "" non viene disegnato # opacity = 0-100 oldFmt = self.styleSheet().split(";") fmt = "rgba({0},{1},{2},{3}%)" c = QColor(foregroundColor) rgbStrForeColor = "color: " + fmt.format(str(c.red()), str( c.green()), str(c.blue()), str(opacity)) + ";" c = QColor(backGroundColor) rgbStrBackColor = "background-color: " + fmt.format( str(c.red()), str(c.green()), str(c.blue()), str(opacity)) + ";" c = QColor(borderColor) rgbStrBorderColor = "border-color: " + fmt.format( str(c.red()), str(c.green()), str(c.blue()), str(opacity)) + ";" fmtBorder = "border:1px;border-style:solid;" c = QColor(selectionColor) rgbStrSelectionColor = "selection-color: " + fmt.format( str(c.red()), str(c.green()), str(c.blue()), str(opacity)) + ";" c = QColor(selectionBackGroundColor) rgbStrSelectionBackColor = "selection-background-color: " + fmt.format( str(c.red()), str(c.green()), str(c.blue()), str(opacity)) + ";" fontSize = 8 + self.size fmt = rgbStrForeColor + \ rgbStrBackColor + \ fmtBorder + \ rgbStrBorderColor + \ rgbStrSelectionColor + \ rgbStrSelectionBackColor + \ "font-size: " + str(fontSize) + "pt;" editWidget.setStyleSheet(fmt)
def set_color(self, variable: str, color: QColor) -> list: """ Produces R code that creates a variable from color input. :param variable: string. Name of the variable. :param color: QColor. Red, green, blue and alpha values. :return: string. R code that constructs the color hex string. """ commands = [] commands.append( '{0} <- rgb({1}, {2}, {3}, {4}, maxColorValue = 255)'.format( variable, color.red(), color.green(), color.blue(), color.alpha())) return commands
def _assertWhite(self, color: QColor): self.assertEqual(color.red(), 255) self.assertEqual(color.green(), 255) self.assertEqual(color.blue(), 255)
def _assertBlack(self, color: QColor): self.assertEqual(color.red(), 0) self.assertEqual(color.green(), 0) self.assertEqual(color.blue(), 255)