Skip to content

Commit

Permalink
Add get_tooltip(), set_tooltip() methods to GUI widgets (mne-tools#10270
Browse files Browse the repository at this point in the history
)
  • Loading branch information
hoechenberger authored Jan 31, 2022
1 parent 69e2ce6 commit 5b788d6
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
12 changes: 12 additions & 0 deletions mne/gui/tests/test_gui_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,18 @@ def _check_widget_trigger(widget, mock, before, after, call_count=True,
renderer._tool_bar_set_theme(theme='dark')
# --- END: tool bar ---

# --- BEGIN: tooltips ---
widget = renderer._dock_add_button(
name='',
callback=mock,
tooltip='foo'
)
assert widget.get_tooltip() == 'foo'
# Change it …
widget.set_tooltip('bar')
assert widget.get_tooltip() == 'bar'
# --- END: tooltips ---

renderer.show()
renderer.close()

Expand Down
8 changes: 8 additions & 0 deletions mne/viz/backends/_abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,14 @@ def is_enabled(self):
def update(self, repaint=True):
pass

@abstractmethod
def get_tooltip(self):
pass

@abstractmethod
def set_tooltip(self, tooltip: str):
pass


class _AbstractMplInterface(ABC):
@abstractmethod
Expand Down
8 changes: 8 additions & 0 deletions mne/viz/backends/_notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,14 @@ def is_enabled(self):
def update(self, repaint=True):
pass

def get_tooltip(self):
assert hasattr(self._widget, 'tooltip')
return self._widget.tooltip

def set_tooltip(self, tooltip):
assert hasattr(self._widget, 'tooltip')
self._widget.tooltip = tooltip


class _Renderer(_PyVistaRenderer, _IpyDock, _IpyToolBar, _IpyMenuBar,
_IpyStatusBar, _IpyWindow, _IpyPlayback):
Expand Down
8 changes: 8 additions & 0 deletions mne/viz/backends/_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,14 @@ def update(self, repaint=True):
if repaint:
self._widget.repaint()

def get_tooltip(self):
assert hasattr(self._widget, 'toolTip')
return self._widget.toolTip()

def set_tooltip(self, tooltip):
assert hasattr(self._widget, 'setToolTip')
self._widget.setToolTip(tooltip)


class _Renderer(_PyVistaRenderer, _QtDock, _QtToolBar, _QtMenuBar,
_QtStatusBar, _QtWindow, _QtPlayback):
Expand Down

0 comments on commit 5b788d6

Please sign in to comment.