Skip to content

Inconsistent signatures of event handlers #10836

Closed
@anntzer

Description

@anntzer

Bug report

Bug summary

The FigureCanvasBase defines the signatures of various event handlers, such as motion_notify_event(self, x, y, guiEvent=None). The qt and wx backends define their own handlers in a GUI-specific fashion (mouseMoveEvent(self, event) for qt (which is the only toolkit to use a subclassing approach), _onMotion(self, evt) + Bind(wx.EVT_MOTION, self._onMotion) for wx); as such, one can programatically trigger an event in a backend-independent fashion on a qt or wx canvas by calling its motion_notify_event method.

On the other hand, the gtk3 and tk backends, which use a registration approach like wx, redefine motion_notify_event to have a different signature that matches what the GUI toolkit expects. The signature of motion_notify_event is (self, widget, event) on gtk3, and (self, event) on tk.

Instead, these handlers should be made private (similarly to how the wx backend does), so that calling canvas.motion_notify_event(x, y) truly works in a backend-independent fashion. (Of course, a proper deprecation period can be implemented by temporarily making these methods take *args and dispatch accordingly.)

Matplotlib version

  • Matplotlib version: master/any

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions