Skip to content

Commit

Permalink
Merge pull request #3140 from pn2200/reset-marker-color
Browse files Browse the repository at this point in the history
BF: Reset marker color after a response
  • Loading branch information
peircej committed Sep 18, 2020
2 parents faa0d6e + 7d7900f commit 66ac190
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions psychopy/visual/ratingscale.py
Expand Up @@ -857,6 +857,7 @@ def _initMarker(self, marker, markerColor, expansion):
self.markerColor = markerColor
self.markerYpos = self.offsetVert + self.markerOffsetVert
# save initial state, restore on reset
self.markerColorOriginal = markerColor

def _initTextElements(self, win, scale, textColor,
textFont, textSize, showValue, tickMarks):
Expand Down Expand Up @@ -903,6 +904,16 @@ def _initTextElements(self, win, scale, textColor,
self.origScaleDescription = scale
self.setDescription(scale) # do last

def _setMarkerColor(self, color):
"""Set the fill color or color of the marker"""
try:
self.marker.setFillColor(color, log=False)
except AttributeError:
try:
self.marker.setColor(color, log=False)
except Exception:
pass

def setDescription(self, scale=None, log=True):
"""Method to set the brief description (scale).
Expand Down Expand Up @@ -1144,13 +1155,8 @@ def draw(self, log=True):
if self.noResponse == False:
# fix the marker position on the line
if not self.markerPosFixed:
try:
self.marker.setFillColor('DarkGray', log=False)
except AttributeError:
try:
self.marker.setColor('DarkGray', log=False)
except Exception:
pass
self._setMarkerColor('DarkGray')

# drop it onto the line
self.marker.setPos((0, -.012), ('+', '-')[self.flipVert],
log=False)
Expand Down Expand Up @@ -1331,8 +1337,8 @@ def reset(self, log=True):
labels.setColor(self.textColor, log=False)
self.noResponse = True
# restore in case it turned gray, etc
self.resetMarker = str(self.marker)
self.resetMarker = self.resetMarker.replace('Window(...)', 'self.win')
self.markerColor = self.markerColorOriginal
self._setMarkerColor(self.markerColor)
# placed by subject or markerStart: show on screen
self.markerPlaced = False
# placed by subject is actionable: show value, singleClick
Expand Down

0 comments on commit 66ac190

Please sign in to comment.