Skip to content

Commit

Permalink
Merge pull request #1096 from vasole/style
Browse files Browse the repository at this point in the history
[GUI] Scatter color not shown
  • Loading branch information
vasole authored Nov 26, 2024
2 parents 884bfc0 + 316eda3 commit 5236f91
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/PyMca5/PyMcaGui/physics/xrf/EnergyTable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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 \
Expand All @@ -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
Expand Down Expand Up @@ -632,16 +632,18 @@ 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
self.setAutoFillBackground(1)

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)
Expand All @@ -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)
Expand Down

0 comments on commit 5236f91

Please sign in to comment.