diff --git a/mne_qt_browser/_pg_figure.py b/mne_qt_browser/_pg_figure.py index 88eb208f..8d4d12f2 100644 --- a/mne_qt_browser/_pg_figure.py +++ b/mne_qt_browser/_pg_figure.py @@ -96,6 +96,8 @@ (0, 255, 255): (0, 139, 139), # 'darkcyan' } +_vline_color = (0, 191, 0) + def _get_color(color_spec, invert=False): """Wrap mkColor to accept all possible matplotlib color-specifiers.""" @@ -1340,7 +1342,7 @@ class VLineLabel(InfLineLabel): def __init__(self, vline): super().__init__(vline, text='{value:.3f} s', position=0.98, - fill='g', color='b', movable=True) + fill=_vline_color, color='k', movable=True) self.cursorOffset = None def mouseDragEvent(self, ev): @@ -1376,16 +1378,25 @@ def valueChanged(self): self.setText(self.format.format(value=value)) self.updatePosition() + def hoverEvent(self, ev): + _methpartial(self.line.hoverEvent)(ev) + class VLine(InfiniteLine): """Marker to be placed inside the Trace-Plot.""" def __init__(self, mne, pos, bounds): - super().__init__(pos, pen='g', hoverPen='y', + super().__init__(pos, pen={"color": _vline_color, "width": 2}, hoverPen='y', movable=True, bounds=bounds) self.mne = mne self.label = VLineLabel(self) + def setMouseHover(self, hover): + super().setMouseHover(hover) + # Also change color of label + self.label.fill = self.currentPen.color() + self.label.border = self.currentPen + def _q_font(point_size, bold=False): font = QFont() @@ -3411,6 +3422,7 @@ def __init__(self, **kwargs): # disable histogram of epoch PTP amplitude del self.mne.keyboard_shortcuts["h"] + def _hidpi_mkPen(self, *args, **kwargs): kwargs['width'] = self._pixel_ratio * kwargs.get('width', 1.) return mkPen(*args, **kwargs) @@ -4706,10 +4718,11 @@ def closeEvent(self, event): if getattr(self.mne, 'vline', None) is not None: if self.mne.is_epochs: for vl in self.mne.vline: - _disconnect(vl.sigPositionChangeFinished) + _disconnect(vl.sigPositionChangeFinished, allow_error=True) self.mne.vline.clear() else: - _disconnect(self.mne.vline.sigPositionChangeFinished) + _disconnect(self.mne.vline.sigPositionChangeFinished, + allow_error=True) if getattr(self, 'load_thread', None) is not None: self.load_thread.clean() self.load_thread = None