def testQColor(self): """"Test getQColor function with accepted values""" for name, test in self.TEST_COLORS.items(): color, expected = test with self.subTest(msg=name): result = colors.asQColor(color) self.assertAlmostEqual(result.redF(), expected[0], places=4) self.assertAlmostEqual(result.greenF(), expected[1], places=4) self.assertAlmostEqual(result.blueF(), expected[2], places=4) self.assertAlmostEqual(result.alphaF(), expected[3], places=4)
def getDefaultColor(self, item): """Returns the default ROI color to use according to the given item. :param ~silx.gui.plot.items.item.Item item: AN item :rtype: qt.QColor """ color = 'pink' if isinstance(item, items.ColormapMixIn): colormap = item.getColormap() name = colormap.getName() if name is not None: color = colors.cursorColorForColormap(name) color = colors.asQColor(color) return color