-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
WIP: Add help window to the _TimeViewer #7305
WIP: Add help window to the _TimeViewer #7305
Conversation
mne/viz/_brain/_timeviewer.py
Outdated
cell._loc = 'right' | ||
|
||
fig_help.canvas.draw() | ||
plt_show(fig=fig_help, warn=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please refactor this code with the other help windows in mne/viz
. They should all use a single call, maybe something like:
def _show_help(options):
...
where options
is a list (rows) of 2-element lists (cols)? This would be better than a dict
because you make it so that some of the "rows" are actually blank, or hline, etc. This function would take that input and pop up a window showing the table, this window should be close-able with hitting esc
, etc.
Thanks @GuillaumeFavelier, this will be really useful 🥳 |
Codecov Report
@@ Coverage Diff @@
## master #7305 +/- ##
==========================================
- Coverage 89.83% 89.81% -0.03%
==========================================
Files 449 449
Lines 80791 80801 +10
Branches 12880 12881 +1
==========================================
- Hits 72581 72571 -10
- Misses 5384 5399 +15
- Partials 2826 2831 +5 |
mne/viz/_brain/_timeviewer.py
Outdated
'u': 'Restore original clim', | ||
'Space': 'Start/Pause playback' | ||
} | ||
text = [str(s) + " : \n" for s in shortcuts.keys()] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dict order is only guaranteed in Python 3.6+, we still support 3.5. You can probably just turn this into a tuple, then do
pairs = [
('h', 'Display help window'),
...
]
text1, text2 = zip(*pairs)
text1 = '\n'.join(text1)
text2 = '\n'.join(text2)
We might need to use Qt directly to bind the help window to References: |
This change will affect all the current bindings. |
Isn't it 63? |
My bad. I mean the ascii code returned by I don't see it in the following list: https://github.com/Kitware/VTK/blob/master/GUISupport/Qt/QVTKInteractorAdapter.cxx#L577-L671 |
It might be a good idea to test this new key binding system on different configurations actually (especially |
Not working for me on macOS (on an American keyboard, I tried pressing Had to install |
This reverts commit f7339c5.
Using |
This doesn't fix it for me, sorry :( |
Thanks a lot for your help @hoechenberger ! Apparently there is also |
mne/viz/_brain/_timeviewer.py
Outdated
|
||
def keyPressEvent(self, event): | ||
from PyQt5 import QtCore | ||
if event.key() == QtCore.Qt.Key_questiondown: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works for me on both macOS and Linux
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(BTW if I do print(event.key())
and print(type(event.key())
on macOS I get 63
and int
, so it's possible that using the ASCII char code would have also be enough :) )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But what's confusing to me is that QtCore.Qt.Key_questiondown == 191
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh actually it's not being routed through this part of the conditional at all, it's going through the callback=self.key_mindings.get(event.text())
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hoechenberger tried both event.text()
and Key_Question
without success.
Trying to catch up here.
I just removed it now, does it still work for you @larsoner ? So thanks to:
I believe I can reproduce the behaviour you have, thank you @hoechenberger So when I add I know this is a workaround but |
Working in qtconsole and VS Code interactive Python window! Only annoying thing is the window opens in the background, not sure if that can be fixed? Btw menus are working properly this way too |
Thank you for the fast response,
This is a bug, I will report it on #7162 |
mne/viz/_brain/_timeviewer.py
Outdated
# display help | ||
self.help_actor = self.plotter.add_text( | ||
text="Press ? to show help window" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... actually the intuitive way to do it without eating up screen real estate would be to add a Help->Show MNE key bindings...
menu option at the top. If it's not too hard to do it it's a nice option
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or more completely / standardly, Help-> Show MNE key bindings... ?
(with the ?
in the right column of the menu item to indicate it's the shortcut)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion @larsoner. I'm on it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just need to find this code snippet I did not so long ago...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found it: #7200 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM +1 for merge
Still wondering if a hint in very small font size, "[?] Show key bindings", wouldn't be a good idea. |
Indeed, after doing %matplotlib qt the ? works for me (spyder on Mac).
'press ? for help' (I don't think the term 'key bindings' is very well understood by non-coding experts)
|
I don't think it's worth wasting the screen real estate. Putting a "press this for help" in the "working area" is highly abnormal. Putting help in a help menu at the top is about as standard as you can get. |
Maybe a compromise would be to display the |
Just throwing ideas. This is something we can always improve in another PR anyway, I believe it works as is. |
works great. Can I just suggest some better shortcuts: Toggle interface -> i ? |
Totally. The diff is really small. |
@GuillaumeFavelier Minor glitch but the default help window height is a little too small on my computer, causing visually unpleasant line spacing |
I would increase line spacing if possible but otherwise LGTM !
… |
(btw is there any documentation on auto-scaling somewhere? what does it do, exactly?) |
I'd say for now let's go with the menu. If / when PyVista adds new UI elements and some of the sliders get converted to buttons or dropdown boxes, we can revisit at that point whether there's enough screen space for "press ? for help". |
Fair enough.
No documentation so far. A good start is #7153 (comment) and #7218 |
Thanks @GuillaumeFavelier ! |
Whoops. I changed the title to WIP my bad. Very bad timing I suppose. |
Sorry, missed that change. Just tack whatever you were going to do onto #7247, which we should also merge ASAP |
@GuillaumeFavelier awesome work!!! 🥳 |
* Add help window * Update window size and refactor _show_help() * Use tuple instead of dict * Refactor key bindings * Refactor keyPressEvent * Revert "Refactor keyPressEvent" This reverts commit f7339c5. * TST: try Key_questiondown * Refactor keyPressEvent * Use help menu instead of help label * Update shortcuts
* Add help window * Update window size and refactor _show_help() * Use tuple instead of dict * Refactor key bindings * Refactor keyPressEvent * Revert "Refactor keyPressEvent" This reverts commit f7339c5. * TST: try Key_questiondown * Refactor keyPressEvent * Use help menu instead of help label * Update shortcuts
This PR adds a
matplotlib
figure to display help. The shortcut ish
:mne/viz/utils.py
(suggested in WIP: Add help window to the _TimeViewer #7305 (comment))tuple
instead ofdict
to respect order (suggested in WIP: Add help window to the _TimeViewer #7305 (comment))?
as shortcut to show the help window (suggested in MRG: Enable point picking in _TimeViewer #7247 (comment))Help
menu instead of a label (suggested in WIP: Add help window to the _TimeViewer #7305 (comment))Closes #7268
It's an item of #7162