@@ -1211,9 +1211,10 @@ def _on_timer(self):
1211
1211
1212
1212
class Event :
1213
1213
"""
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.
1217
1218
1218
1219
Attributes
1219
1220
----------
@@ -1232,20 +1233,20 @@ def __init__(self, name, canvas, guiEvent=None):
1232
1233
1233
1234
class DrawEvent (Event ):
1234
1235
"""
1235
- An event triggered by a draw operation on the canvas
1236
+ An event triggered by a draw operation on the canvas.
1236
1237
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``.
1241
1242
1242
1243
.. warning::
1243
1244
1244
1245
Calling ``canvas.draw`` and ``canvas.blit`` in these callbacks may
1245
1246
not be safe with all backends and may cause infinite recursion.
1246
1247
1247
- In addition to the `Event` attributes, the following event
1248
- attributes are defined:
1248
+ A DrawEvent has a number of special attributes in addition to those defined
1249
+ by the parent `Event` class.
1249
1250
1250
1251
Attributes
1251
1252
----------
@@ -1259,10 +1260,10 @@ def __init__(self, name, canvas, renderer):
1259
1260
1260
1261
class ResizeEvent (Event ):
1261
1262
"""
1262
- An event triggered by a canvas resize
1263
+ An event triggered by a canvas resize.
1263
1264
1264
- In addition to the `Event` attributes, the following event
1265
- attributes are defined:
1265
+ A ResizeEvent has a number of special attributes in addition to those
1266
+ defined by the parent `Event` class.
1266
1267
1267
1268
Attributes
1268
1269
----------
@@ -1284,32 +1285,23 @@ class LocationEvent(Event):
1284
1285
"""
1285
1286
An event that has a screen location.
1286
1287
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
+ A LocationEvent has a number of special attributes in addition to those
1289
+ defined by the parent `Event` class.
1292
1290
1293
1291
Attributes
1294
1292
----------
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
+ Event location in pixels from bottom left of canvas.
1299
1295
inaxes : `~.axes.Axes` or None
1300
1296
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.
1305
1300
"""
1306
1301
1307
1302
lastevent = None # the last event that was triggered before this one
1308
1303
1309
1304
def __init__ (self , name , canvas , x , y , guiEvent = None ):
1310
- """
1311
- (*x*, *y*) in figure coords ((0, 0) = bottom left).
1312
- """
1313
1305
super ().__init__ (name , canvas , guiEvent = guiEvent )
1314
1306
# x position - pixels from left of canvas
1315
1307
self .x = int (x ) if x is not None else x
@@ -1378,13 +1370,11 @@ class MouseButton(IntEnum):
1378
1370
1379
1371
class MouseEvent (LocationEvent ):
1380
1372
"""
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').
1385
1375
1386
- In addition to the `Event` and `LocationEvent`
1387
- attributes, the following attributes are defined:
1376
+ A MouseEvent has a number of special attributes in addition to those
1377
+ defined by the parent `Event` and `LocationEvent` classes.
1388
1378
1389
1379
Attributes
1390
1380
----------
@@ -1426,10 +1416,6 @@ def on_press(event):
1426
1416
1427
1417
def __init__ (self , name , canvas , x , y , button = None , key = None ,
1428
1418
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
- """
1433
1419
if button in MouseButton .__members__ .values ():
1434
1420
button = MouseButton (button )
1435
1421
self .button = button
@@ -1450,11 +1436,14 @@ def __str__(self):
1450
1436
1451
1437
class PickEvent (Event ):
1452
1438
"""
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
1454
1442
sufficiently close to an artist that has been made pickable with
1455
1443
`.Artist.set_picker`.
1456
1444
1457
- Attrs: all the `Event` attributes plus
1445
+ A PickEvent has a number of special attributes in addition to those defined
1446
+ by the parent `Event` class.
1458
1447
1459
1448
Attributes
1460
1449
----------
@@ -1495,19 +1484,16 @@ class KeyEvent(LocationEvent):
1495
1484
"""
1496
1485
A key event (key press, key release).
1497
1486
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
+ A KeyEvent has a number of special attributes in addition to those defined
1488
+ by the parent `Event` and `LocationEvent` classes.
1503
1489
1504
1490
Attributes
1505
1491
----------
1506
1492
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 Unicode
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").
1511
1497
1512
1498
Notes
1513
1499
-----
0 commit comments