8000 Clean up some Event class docs. · matplotlib/matplotlib@85e5687 · GitHub
[go: up one dir, main page]

Skip to content

Commit 85e5687

Browse files
committed
Clean up some Event class docs.
1 parent 298e92f commit 85e5687

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
@@ -1211,9 +1211,10 @@ def _on_timer(self):
12111211

12121212
class Event:
12131213
"""
1214-
A Matplotlib event. Attach additional attributes as defined in
1215-
:meth:`FigureCanvasBase.mpl_connect`. The following attributes
1216-
are defined and shown with their default values
1214+
A Matplotlib event.
1215+
1216+
The following attributes are defined and shown with their default values.
1217+
Subclasses may define additional attributes.
12171218
12181219
Attributes
12191220
----------
@@ -1232,12 +1233,12 @@ def __init__(self, name, canvas, guiEvent=None):
12321233

12331234
class DrawEvent(Event):
12341235
"""
1235-
An event triggered by a draw operation on the canvas
1236+
An event triggered by a draw operation on the canvas.
12361237
1237-
In most backends callbacks subscribed to this callback will be
1238-
fired after the rendering is complete but before the screen is
1239-
updated. Any extra artists drawn to the canvas's renderer will
1240-
be reflected without an explicit call to ``blit``.
1238+
In most backends, callbacks subscribed to this event will be fired after
1239+
the rendering is complete but before the screen is updated. Any extra
1240+
artists drawn to the canvas's renderer will be reflected without an
1241+
explicit call to ``blit``.
12411242
12421243
.. warning::
12431244
@@ -1259,7 +1260,7 @@ def __init__(self, name, canvas, renderer):
12591260

12601261
class ResizeEvent(Event):
12611262
"""
1262-
An event triggered by a canvas resize
1263+
An event triggered by a canvas resize.
12631264
12641265
In addition to the `Event` attributes, the following event
12651266
attributes are defined:
@@ -1284,32 +1285,23 @@ class LocationEvent(Event):
12841285
"""
12851286
An event that has a screen location.
12861287
1287-
The following additional attributes are defined and shown with
1288-
their default values.
1289-
1290-
In addition to the `Event` attributes, the following
1291-
event attributes are defined:
1288+
In addition to the `Event` attributes, the following event attributes are
1289+
defined:
12921290
12931291
Attributes
12941292
----------
1295-
x : int
1296-
x position - pixels from left of canvas.
1297-
y : int
1298-
y position - pixels from bottom of canvas.
1293+
x, y : int or None
1294+
Position in figure coordinates (pixels from bottom left of canvas).
12991295
inaxes : `~.axes.Axes` or None
13001296
The `~.axes.Axes` instance over which the mouse is, if any.
1301-
xdata : float or None
1302-
x data coordinate of the mouse.
1303-
ydata : float or None
1304-
y data coordinate of the mouse.
1297+
xdata, ydata : float or None
1298+
Data coordinates of the mouse within *inaxes*, or *None* if the mouse
1299+
is not over an Axes.
13051300
"""
13061301

13071302
lastevent = None # the last event that was triggered before this one
13081303

13091304
def __init__(self, name, canvas, x, y, guiEvent=None):
1310-
"""
1311-
(*x*, *y*) in figure coords ((0, 0) = bottom left).
1312-
"""
13131305
super().__init__(name, canvas, guiEvent=guiEvent)
13141306
# x position - pixels from left of canvas
13151307
self.x = int(x) if x is not None else x
@@ -1378,13 +1370,11 @@ class MouseButton(IntEnum):
13781370

13791371
class MouseEvent(LocationEvent):
13801372
"""
1381-
A mouse event ('button_press_event',
1382-
'button_release_event',
1383-
'scroll_event',
1384-
'motion_notify_event').
1373+
A mouse event ('button_press_event', 'button_release_event', \
1374+
'scroll_event', 'motion_notify_event').
13851375
1386-
In addition to the `Event` and `LocationEvent`
1387-
attributes, the following attributes are defined:
1376+
In addition to the `Event` and `LocationEvent` attributes, the below event
1377+
attributes are defined.
13881378
13891379
Attributes
13901380
----------
@@ -1426,10 +1416,6 @@ def on_press(event):
14261416

14271417
def __init__(self, name, canvas, x, y, button=None, key=None,
14281418
step=0, dblclick=False, guiEvent=None):
1429-
"""
1430-
(*x*, *y*) in figure coords ((0, 0) = bottom left)
1431-
button pressed None, 1, 2, 3, 'up', 'down'
1432-
"""
14331419
if button in MouseButton.__members__.values():
14341420
button = MouseButton(button)
14351421
self.button = button
@@ -1450,11 +1436,14 @@ def __str__(self):
14501436

14511437
class PickEvent(Event):
14521438
"""
1453-
A pick event, fired when the user picks a location on the canvas
1439+
A pick event.
1440+
1441+
This event is fired when the user picks a location on the canvas
14541442
sufficiently close to an artist that has been made pickable with
14551443
`.Artist.set_picker`.
14561444
1457-
Attrs: all the `Event` attributes plus
1445+
In addition to the `Event` attributes, the below event attributes are
1446+
defined.
14581447
14591448
Attributes
14601449
----------
@@ -1495,19 +1484,16 @@ class KeyEvent(LocationEvent):
14951484
"""
14961485
A key event (key press, key release).
14971486
1498-
Attach additional attributes as defined in
1499-
:meth:`FigureCanvasBase.mpl_connect`.
1500-
1501-
In addition to the `Event` and `LocationEvent`
1502-
attributes, the following attributes are defined:
1487+
In addition to the `Event` and `LocationEvent` attributes, the below event
1488+
attributes are defined.
15031489
15041490
Attributes
15051491
----------
15061492
key : None or str
1507-
the key(s) pressed. Could be **None**, a single case sensitive ascii
1508-
character ("g", "G", "#", etc.), a special key
1509-
("control", "shift", "f1", "up", etc.) or a
1510-
combination of the above (e.g., "ctrl+alt+g", "ctrl+alt+G").
1493+
The key(s) pressed. Could be *None*, a single case sensitive ASCII
1494+
character ("g", "G", "#", etc.), a special key ("control", "shift",
1495+
"f1", "up", etc.) or a combination of the above (e.g., "ctrl+alt+g",
1496+
"ctrl+alt+G").
15111497
15121498
Notes
15131499
-----

0 commit comments

Comments
 (0)
0