Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ea590ce

Browse files
committed
Fix test_mouseclicks.py on Python 3
1 parent a720fd7 commit ea590ce

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

examples/event_handling/test_mouseclicks.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/usr/bin/env python
2+
from __future__ import print_function
3+
24
import matplotlib
35
#matplotlib.use("WxAgg")
46
#matplotlib.use("TkAgg")
@@ -9,23 +11,25 @@
911
#matplotlib.use("MacOSX")
1012
import matplotlib.pyplot as plt
1113

12-
#print "***** TESTING WITH BACKEND: %s"%matplotlib.get_backend() + " *****"
14+
#print("***** TESTING WITH BACKEND: %s"%matplotlib.get_backend() + " *****")
15+
1316

1417
def OnClick(event):
15-
if event.dblclick:
16-
print "DBLCLICK",event
17-
else:
18-
print "DOWN ",event
18+
if event.dblclick:
19+
print("DBLCLICK", event)
20+
else:
21+
print("DOWN ", event)
22+
1923

2024
def OnRelease(event):
21-
print "UP ",event
25+
print("UP ", event)
2226

2327

2428
fig = plt.gcf()
25-
cid_up = fig.canvas.mpl_connect('button_press_event',OnClick)
26-
cid_down = fig.canvas.mpl_connect('button_release_event',OnRelease)
29+
cid_up = fig.canvas.mpl_connect('button_press_event', OnClick)
30+
cid_down = fig.canvas.mpl_connect('button_release_event', OnRelease)
2731

28-
plt.gca().text(0.5,0.5,"Click on the canvas to test mouse events.",ha="center",va="center")
32+
plt.gca().text(0.5, 0.5, "Click on the canvas to test mouse events.",
33+
ha="center", va="center")
2934

3035
plt.show()
31-

0 commit comments

Comments
 (0)