Skip to content

Commit 90f2661

Browse files
committed
Clean up some Event class docs.
1 parent e13f0bd commit 90f2661

File tree

1 file changed

+32
-46
lines changed

1 file changed

+32
-46
lines changed

lib/matplotlib/backend_bases.py

Lines changed: 32 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,9 +1209,10 @@ def _on_timer(self):
12091209

12101210
class Event:
12111211
"""
1212-
A Matplotlib event. Attach additional attributes as defined in
1213-
:meth:`FigureCanvasBase.mpl_connect`. The following attributes
1214-
are defined and shown with their default values
1212+
A Matplotlib event.
1213+
1214+
The following attributes are defined and shown with their default values.
1215+
Subclasses may define additional attributes.
12151216
12161217
Attributes
12171218
----------
@@ -1230,12 +1231,12 @@ def __init__(self, name, canvas, guiEvent=None):
12301231

12311232
class DrawEvent(Event):
12321233
"""
1233-
An event triggered by a draw operation on the canvas
1234+
An event triggered by a draw operation on the canvas.
12341235
1235-
In most backends callbacks subscribed to this callback will be
1236-
fired after the rendering is complete but before the screen is
1237-
updated. Any extra artists drawn to the canvas's renderer will
1238-
be reflected without an explicit call to ``blit``.
1236+
In most backends, callbacks subscribed to this event will be fired after
1237+
the rendering is complete but before the screen is updated. Any extra
1238+
artists drawn to the canvas's renderer will be reflected without an
1239+
explicit call to ``blit``.
12391240
12401241
.. warning::
12411242
@@ -1257,7 +1258,7 @@ def __init__(self, name, canvas, renderer):
12571258

12581259
class ResizeEvent(Event):
12591260
"""
1260-
An event triggered by a canvas resize
1261+
An event triggered by a canvas resize.
12611262
12621263
In addition to the `Event` attributes, the following event
12631264
attributes are defined:
@@ -1282,32 +1283,23 @@ class LocationEvent(Event):
12821283
"""
12831284
An event that has a screen location.
12841285
1285-
The following additional attributes are defined and shown with
1286-
their default values.
1287-
1288-
In addition to the `Event` attributes, the following
1289-
event attributes are defined:
1286+
In addition to the `Event` attributes, the following event attributes are
1287+
defined:
12901288
12911289
Attributes
12921290
----------
1293-
x : int
1294-
x position - pixels from left of canvas.
1295-
y : int
1296-
y position - pixels from bottom of canvas.
1291+
x, y : int or None
1292+
Position in figure coordinates (pixels from bottom left of canvas).
12971293
inaxes : `~.axes.Axes` or None
12981294
The `~.axes.Axes` instance over which the mouse is, if any.
1299-
xdata : float or None
1300-
x data coordinate of the mouse.
1301-
ydata : float or None
1302-
y data coordinate of the mouse.
1295+
xdata, ydata : float or None
1296+
Data coordinates of the mouse within *inaxes*, or *None* if the mouse
1297+
is not over an Axes.
13031298
"""
13041299

13051300
lastevent = None # the last event that was triggered before this one
13061301

13071302
def __init__(self, name, canvas, x, y, guiEvent=None):
1308-
"""
1309-
(*x*, *y*) in figure coords ((0, 0) = bottom left).
1310-
"""
13111303
super().__init__(name, canvas, guiEvent=guiEvent)
13121304
# x position - pixels from left of canvas
13131305
self.x = int(x) if x is not None else x
@@ -1376,13 +1368,11 @@ class MouseButton(IntEnum):
13761368

13771369
class MouseEvent(LocationEvent):
13781370
"""
1379-
A mouse event ('button_press_event',
1380-
'button_release_event',
1381-
'scroll_event',
1382-
'motion_notify_event').
1371+
A mouse event ('button_press_event', 'button_release_event', \
1372+
'scroll_event', 'motion_notify_event').
13831373
1384-
In addition to the `Event` and `LocationEvent`
1385-
attributes, the following attributes are defined:
1374+
In addition to the `Event` and `LocationEvent` attributes, the below event
1375+
attributes are defined.
13861376
13871377
Attributes
13881378
----------
@@ -1424,10 +1414,6 @@ def on_press(event):
14241414

14251415
def __init__(self, name, canvas, x, y, button=None, key=None,
14261416
step=0, dblclick=False, guiEvent=None):
1427-
"""
1428-
(*x*, *y*) in figure coords ((0, 0) = bottom left)
1429-
button pressed None, 1, 2, 3, 'up', 'down'
1430-
"""
14311417
if button in MouseButton.__members__.values():
14321418
button = MouseButton(button)
14331419
self.button = button
@@ -1448,11 +1434,14 @@ def __str__(self):
14481434

14491435
class PickEvent(Event):
14501436
"""
1451-
A pick event, fired when the user picks a location on the canvas
1437+
A pick event.
1438+
1439+
This event is fired when the user picks a location on the canvas
14521440
sufficiently close to an artist that has been made pickable with
14531441
`.Artist.set_picker`.
14541442
1455-
Attrs: all the `Event` attributes plus
1443+
In addition to the `Event` attributes, the below event attributes are
1444+
defined.
14561445
14571446
Attributes
14581447
----------
@@ -1493,19 +1482,16 @@ class KeyEvent(LocationEvent):
14931482
"""
14941483
A key event (key press, key release).
14951484
1496-
Attach additional attributes as defined in
1497-
:meth:`FigureCanvasBase.mpl_connect`.
1498-
1499-
In addition to the `Event` and `LocationEvent`
1500-
attributes, the following attributes are defined:
1485+
In addition to the `Event` and `LocationEvent` attributes, the below event
1486+
attributes are defined.
15011487
15021488
Attributes
15031489
----------
15041490
key : None or str
1505-
the key(s) pressed. Could be **None**, a single case sensitive ascii
1506-
character ("g", "G", "#", etc.), a special key
1507-
("control", "shift", "f1", "up", etc.) or a
1508-
combination of the above (e.g., "ctrl+alt+g", "ctrl+alt+G").
1491+
The key(s) pressed. Could be *None*, a single case sensitive ASCII
1492+
character ("g", "G", "#", etc.), a special key ("control", "shift",
1493+
"f1", "up", etc.) or a combination of the above (e.g., "ctrl+alt+g",
1494+
"ctrl+alt+G").
15091495
15101496
Notes
15111497
-----

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy