@@ -1040,29 +1040,23 @@ class TimerBase:
10401040 own timing mechanisms so that the timer events are integrated into their
10411041 event loops.
10421042
1043- Mandatory functions that must be implemented :
1043+ Subclasses must override the following methods :
10441044
1045- * ` _timer_start`: Contains backend -specific code for starting
1046- the timer
1045+ - `` _timer_start``: Backend -specific code for starting the timer.
1046+ - ``_timer_stop``: Backend-specific code for stopping the timer.
10471047
1048- * `_timer_stop`: Contains backend-specific code for stopping
1049- the timer
1048+ Subclasses may additionally override the following methods:
10501049
1051- Optional overrides:
1050+ - ``_timer_set_single_shot``: Code for setting the timer to single shot
1051+ operating mode, if supported by the timer object. If not, the `Timer`
1052+ class itself will store the flag and the ``_on_timer`` method should be
1053+ overridden to support such behavior.
10521054
1053- * `_timer_set_single_shot`: Code for setting the timer to
1054- single shot operating mode, if supported by the timer
1055- object. If not, the `Timer` class itself will store the flag
1056- and the `_on_timer` method should be overridden to support
1057- such behavior.
1055+ - ``_timer_set_interval``: Code for setting the interval on the timer, if
1056+ there is a method for doing so on the timer object.
10581057
1059- * `_timer_set_interval`: Code for setting the interval on the
1060- timer, if there is a method for doing so on the timer
1061- object.
1062-
1063- * `_on_timer`: This is the internal function that any timer
1064- object should call, which will handle the task of running
1065- all callbacks that have been set.
1058+ - ``_on_timer``: The internal function that any timer object should call,
1059+ which will handle the task of running all callbacks that have been set.
10661060
10671061 Attributes
10681062 ----------
@@ -1419,8 +1413,7 @@ class MouseEvent(LocationEvent):
14191413
14201414 Examples
14211415 --------
1422- Usage::
1423-
1416+ ::
14241417 def on_press(event):
14251418 print('you pressed', event.button, event.xdata, event.ydata)
14261419
@@ -1471,8 +1464,7 @@ class PickEvent(Event):
14711464
14721465 Examples
14731466 --------
1474- Usage::
1475-
1467+ ::
14761468 ax.plot(np.rand(100), 'o', picker=5) # 5 points tolerance
14771469
14781470 def on_pick(event):
@@ -1482,7 +1474,6 @@ def on_pick(event):
14821474 print('on pick line:', np.array([xdata[ind], ydata[ind]]).T)
14831475
14841476 cid = fig.canvas.mpl_connect('pick_event', on_pick)
1485-
14861477 """
14871478 def __init__ (self , name , canvas , mouseevent , artist ,
14881479 guiEvent = None , ** kwargs ):
@@ -1519,13 +1510,11 @@ class KeyEvent(LocationEvent):
15191510
15201511 Examples
15211512 --------
1522- Usage::
1523-
1513+ ::
15241514 def on_key(event):
15251515 print('you pressed', event.key, event.xdata, event.ydata)
15261516
15271517 cid = fig.canvas.mpl_connect('key_press_event', on_key)
1528-
15291518 """
15301519 def __init__ (self , name , canvas , key , x = 0 , y = 0 , guiEvent = None ):
15311520 LocationEvent .__init__ (self , name , canvas , x , y , guiEvent = guiEvent )
@@ -2164,44 +2153,50 @@ def switch_backends(self, FigureCanvasClass):
21642153
21652154 def mpl_connect (self , s , func ):
21662155 """
2167- Connect event with string *s* to *func*. The signature of *func* is::
2168-
2169- def func(event)
2170-
2171- where event is a :class:`matplotlib.backend_bases.Event`. The
2172- following events are recognized
2173-
2174- - 'button_press_event'
2175- - 'button_release_event'
2176- - 'draw_event'
2177- - 'key_press_event'
2178- - 'key_release_event'
2179- - 'motion_notify_event'
2180- - 'pick_event'
2181- - 'resize_event'
2182- - 'scroll_event'
2183- - 'figure_enter_event',
2184- - 'figure_leave_event',
2185- - 'axes_enter_event',
2186- - 'axes_leave_event'
2187- - 'close_event'
2188-
2189- For the location events (button and key press/release), if the
2190- mouse is over the axes, the variable ``event.inaxes`` will be
2191- set to the :class:`~matplotlib.axes.Axes` the event occurs is
2192- over, and additionally, the variables ``event.xdata`` and
2193- ``event.ydata`` will be defined. This is the mouse location
2194- in data coords. See
2195- :class:`~matplotlib.backend_bases.KeyEvent` and
2196- :class:`~matplotlib.backend_bases.MouseEvent` for more info.
2197-
2198- Return value is a connection id that can be used with
2199- :meth:`~matplotlib.backend_bases.Event.mpl_disconnect`.
2156+ Bind function *func* to event *s*.
2157+
2158+ Parameters
2159+ ----------
2160+ s : str
2161+ One of the following events ids:
2162+
2163+ - 'button_press_event'
2164+ - 'button_release_event'
2165+ - 'draw_event'
2166+ - 'key_press_event'
2167+ - 'key_release_event'
2168+ - 'motion_notify_event'
2169+ - 'pick_event'
2170+ - 'resize_event'
2171+ - 'scroll_event'
2172+ - 'figure_enter_event',
2173+ - 'figure_leave_event',
2174+ - 'axes_enter_event',
2175+ - 'axes_leave_event'
2176+ - 'close_event'.
2177+
2178+ func : callable
2179+ The callback function to be executed, which must have the
2180+ signature::
2181+
2182+ def func(event: Event) -> Any
2183+
2184+ For the location events (button and key press/release), if the
2185+ mouse is over the axes, the ``inaxes`` attribute of the event will
2186+ be set to the `~matplotlib.axes.Axes` the event occurs is over, and
2187+ additionally, the variables ``xdata`` and ``ydata`` attributes will
2188+ be set to the mouse location in data coordinates. See `.KeyEvent`
2189+ and `.MouseEvent` for more info.
2190+
2191+ Returns
2192+ -------
2193+ cid
2194+ A connection id that can be used with
2195+ `.FigureCanvasBase.mpl_disconnect`.
22002196
22012197 Examples
22022198 --------
2203- Usage::
2204-
2199+ ::
22052200 def on_press(event):
22062201 print('you pressed', event.button, event.xdata, event.ydata)
22072202
@@ -2212,24 +2207,23 @@ def on_press(event):
22122207
22132208 def mpl_disconnect (self , cid ):
22142209 """
2215- Disconnect callback id cid
2210+ Disconnect the callback with id * cid*.
22162211
22172212 Examples
22182213 --------
2219- Usage::
2220-
2214+ ::
22212215 cid = canvas.mpl_connect('button_press_event', on_press)
2222- #...later
2216+ # ... later
22232217 canvas.mpl_disconnect(cid)
22242218 """
22252219 return self .callbacks .disconnect (cid )
22262220
22272221 def new_timer (self , * args , ** kwargs ):
22282222 """
2229- Creates a new backend-specific subclass of
2230- :class:`backend_bases.Timer`. This is useful for getting periodic
2231- events through the backend's native event loop. Implemented only for
2232- backends with GUIs.
2223+ Create a new backend-specific subclass of `.Timer`.
2224+
2225+ This is useful for getting periodic events through the backend's native
2226+ event loop. Implemented only for backends with GUIs.
22332227
22342228 Other Parameters
22352229 ----------------
@@ -2240,13 +2234,12 @@ def new_timer(self, *args, **kwargs):
22402234 Sequence of (func, args, kwargs) where ``func(*args, **kwargs)``
22412235 will be executed by the timer every *interval*.
22422236
2243- callbacks which return ``False`` or ``0`` will be removed from the
2237+ Callbacks which return ``False`` or ``0`` will be removed from the
22442238 timer.
22452239
22462240 Examples
22472241 --------
22482242 >>> timer = fig.canvas.new_timer(callbacks=[(f1, (1, ), {'a': 3}),])
2249-
22502243 """
22512244 return TimerBase (* args , ** kwargs )
22522245
0 commit comments