8000 Merge pull request #13091 from anntzer/mouseevent-str · matplotlib/matplotlib@a7f129c · GitHub
[go: up one dir, main page]

Skip to content

Commit a7f129c

Browse files
authored
Merge pull request #13091 from anntzer/mouseevent-str
Improve MouseEvent str().
2 parents 13a617b + 7f4989e commit a7f129c

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
MouseEvents now include the event name in their ``str()``
2+
`````````````````````````````````````````````````````````
3+
4+
... instead of the prefix "MPL MouseEvent".

lib/matplotlib/backend_bases.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,12 +1265,7 @@ def __init__(self, name, canvas):
12651265

12661266

12671267
class CloseEvent(Event):
1268-
"""
1269-
An event triggered by a figure being closed
1270-
1271-
"""
1272-
def __init__(self, name, canvas, guiEvent=None):
1273-
Event.__init__(self, name, canvas, guiEvent)
1268+
"""An event triggered by a figure being closed."""
12741269

12751270

12761271
class LocationEvent(Event):
@@ -1432,10 +1427,10 @@ def __init__(self, name, canvas, x, y, button=None, key=None,
14321427
self.dblclick = dblclick
14331428

14341429
def __str__(self):
1435-
return ("MPL MouseEvent: xy=(%d,%d) xydata=(%s,%s) button=%s " +
1436-
"dblclick=%s inaxes=%s") % (self.x, self.y, self.xdata,
1437-
self.ydata, self.button,
1438-
self.dblclick, self.inaxes)
1430+
return (f"{self.name}: "
1431+
f"xy=({self.x}, {self.y}) xydata=({self.xdata}, {self.ydata}) "
1432+
f"button={self.button} dblclick={self.dblc 4E74 lick} "
1433+
f"inaxes={self.inaxes}")
14391434

14401435

14411436
class PickEvent(Event):

0 commit comments

Comments
 (0)
0