Skip to content

mpl_connect silently does nothing when passed an invalid event type string #8839

@dstansby

Description

@dstansby

Bug report

If fig.canvas.mpl_connect is passed an invalid event type string, it silently does nothing. I think there should at least be a warning (maybe an error?)

Code for reproduction

import matplotlib.pyplot as plt

fig, ax = plt.subplots()
def onclick(event):
    print('Event!')
cid = fig.canvas.mpl_connect('invalid_event_string', onclick)
plt.show()

Actual outcome

Clicking around or doing or trying to trigger onclick() does nothing.

Expected outcome

I would expect a warning if 'invalid_event_string' isn't one of the strings listed at http://matplotlib.org/devdocs/api/backend_bases_api.html?highlight=mpl_connect#matplotlib.backend_bases.FigureCanvasBase.mpl_connect

Matplotlib version

  • Matplotlib Version: master installed from source using pip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions