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

Enh browserfig UI events #12819

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from
Draft
Changes from 2 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
7 changes: 6 additions & 1 deletion mne/viz/ui_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ def _get_event_channel(fig):
import matplotlib

from ._brain import Brain
from ._figure import BrowserBase
from .evoked_field import EvokedField

# Create the event channel if it doesn't exist yet
Expand Down Expand Up @@ -263,9 +264,13 @@ def delete_event_channel(event=None, *, weakfig=weakfig):
# Hook up the above callback function to the close event of the figure
# window. How this is done exactly depends on the various figure types
# MNE-Python has.
_validate_type(fig, (matplotlib.figure.Figure, Brain, EvokedField), "fig")
_validate_type(
fig, (matplotlib.figure.Figure, Brain, EvokedField, BrowserBase), "fig"
)
if isinstance(fig, matplotlib.figure.Figure):
fig.canvas.mpl_connect("close_event", delete_event_channel)
elif isinstance(fig, BrowserBase):
fig.mne.viewbox.destroyed.connect(delete_event_channel)
nmarkowitz marked this conversation as resolved.
Show resolved Hide resolved
else:
assert hasattr(fig, "_renderer") # figures like Brain, EvokedField, etc.
fig._renderer._window_close_connect(delete_event_channel, after=False)
Expand Down
Loading