From 316eda30de98e06ac68bcae3b62d6331336da5cf Mon Sep 17 00:00:00 2001 From: "V. Armando Sole" Date: Tue, 26 Nov 2024 11:02:04 +0100 Subject: [PATCH] use style sheet --- src/PyMca5/PyMcaGui/physics/xrf/EnergyTable.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/PyMca5/PyMcaGui/physics/xrf/EnergyTable.py b/src/PyMca5/PyMcaGui/physics/xrf/EnergyTable.py index ee565cdd4..452410d71 100644 --- a/src/PyMca5/PyMcaGui/physics/xrf/EnergyTable.py +++ b/src/PyMca5/PyMcaGui/physics/xrf/EnergyTable.py @@ -360,7 +360,7 @@ def _doubleClickSlot(self, row, col): if oldcolor != self._scatterColor: item.setColor(self._scatterColor) else: - item.setColor(qt.Qt.white) + item.setColor(qt.QColor(255, 255, 255)) item.repaint(item.rect()) self.cellChanged.emit(row, col) @@ -384,7 +384,7 @@ def __build(self,nrows=None): rowoffset= (-int(idx/self.__rows))*(nrows //self.dataColumns) coloffset= 3*int(idx/self.__rows) r = idx + rowoffset - color = qt.Qt.white + color = qt.QColor(255, 255, 255) if len(self.scatterList): if idx < len(self.scatterList): if (self.scatterList[idx] is not None)and \ @@ -405,7 +405,7 @@ def __build(self,nrows=None): self.setCellWidget(r, 0+coloffset, item) item.stateChanged[int].connect(self._itemSlot) if hasattr(item, "setToolTip"): - item.setToolTip("Double click on empty space at the to toggle inclusion as scatter peak (different color)") + item.setToolTip("Double click on empty space at the end to toggle inclusion as scatter peak (different color)") else: item.setText(text) oldcolor = item.color @@ -632,9 +632,9 @@ def _getDict(self): return ddict class ColorQTableItem(qt.QCheckBox): - def __init__(self, table, text, color=qt.Qt.white,bold=0): + def __init__(self, table, text, color=qt.QColor(255, 255, 255), bold=0): qt.QCheckBox.__init__(self, table) - self.color = color + self.setColor(color) self.bold = bold self.setText(text) #this is one critical line @@ -642,6 +642,8 @@ def __init__(self, table, text, color=qt.Qt.white,bold=0): def setColor(self, color): self.color = color + if hasattr(color, "name"): + self.setStyleSheet("background-color: %s" % color.name()) def paintEvent(self, painter): #this is the other (self.palette() is not appropriate) @@ -660,7 +662,7 @@ def dummy(ddict): energy = numpy.arange(100.).astype(numpy.float64)+ 1.5 weight = numpy.ones(len(energy), numpy.float64) flag = numpy.zeros(len(energy), dtype=numpy.int32).tolist() - scatterlist = numpy.zeros(len(energy)) + scatterlist = numpy.zeros(len(energy)).astype(numpy.int8) scatterlist[0:10] = 1 tab.setParameters(energy, weight, flag, scatterlist) tab.sigEnergyTableSignal.connect(dummy)