Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GUI] Scatter color not shown #1096

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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