Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a464694

Browse filesBrowse files
authored
Merge pull request #29898 from anabelle2001/my_revision
backend_bases.pyi: `@overload` `FigureCanvasBase.mpl_connect()` for different event types
2 parents 26d482b + e879919 commit a464694
Copy full SHA for a464694

File tree

1 file changed

+35
-1
lines changed
Filter options

1 file changed

+35
-1
lines changed

‎lib/matplotlib/backend_bases.pyi

Copy file name to clipboardExpand all lines: lib/matplotlib/backend_bases.pyi
+35-1Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ from matplotlib.text import Text
1919
from matplotlib.transforms import Bbox, BboxBase, Transform, TransformedPath
2020

2121
from collections.abc import Callable, Iterable, Sequence
22-
from typing import Any, IO, Literal, NamedTuple, TypeVar
22+
from typing import Any, IO, Literal, NamedTuple, TypeVar, overload
2323
from numpy.typing import ArrayLike
2424
from .typing import ColorType, LineStyleType, CapStyleType, JoinStyleType
2525

@@ -352,6 +352,40 @@ class FigureCanvasBase:
352352
def get_default_filetype(cls) -> str: ...
353353
def get_default_filename(self) -> str: ...
354354
_T = TypeVar("_T", bound=FigureCanvasBase)
355+
356+
@overload
357+
def mpl_connect(
358+
self,
359+
s: Literal[
360+
"button_press_event",
361+
"motion_notify_event",
362+
"scroll_event",
363+
"figure_enter_event",
364+
"figure_leave_event",
365+
"axes_enter_event",
366+
"axes_leave_event",
367+
"button_release_event",
368+
],
369+
func: Callable[[MouseEvent], Any],
370+
) -> int: ...
371+
372+
@overload
373+
def mpl_connect(
374+
self,
375+
s: Literal["key_press_event", "key_release_event"],
376+
func: Callable[[KeyEvent], Any],
377+
) -> int: ...
378+
379+
@overload
380+
def mpl_connect(self, s: Literal["pick_event"], func: Callable[[PickEvent], Any]) -> int: ...
381+
382+
@overload
383+
def mpl_connect(self, s: Literal["resize_event"], func: Callable[[ResizeEvent], Any]) -> int: ...
384+
385+
@overload
386+
def mpl_connect(self, s: Literal["close_event"], func: Callable[[CloseEvent], Any]) -> int: ...
387+
388+
@overload
355389
def mpl_connect(self, s: str, func: Callable[[Event], Any]) -> int: ...
356390
def mpl_disconnect(self, cid: int) -> None: ...
357391
def new_timer(

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.