Skip to content

How do I disable the Esc key from closing raw.plot? #6425

@cbrnr

Description

@cbrnr

In MNELAB, I would like my raw.plot window to not close if the user hits the Esc key. Previously, I used the following hack which worked for matplotlib < 3:

 try:
    key_events = fig.canvas.callbacks.callbacks["key_press_event"][8]
except KeyError:
    pass
else:  # this requires MNE >=0.15
    key_events.func.keywords["params"]["close_key"] = None

Of course this was bound to fail, and with matplotlib >= 3 key_events is now a matplotlib.cbook._StrongRef object, whereas previously it used to be a matplotlib.cbook._BoundMethodProxy object. Of course private methods can change at anytime, but does anyone know either how to make the old hack work again, or better yet how to modify/delete existing callbacks?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions