Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix test_mouseclicks.py on Python 3 #979

Merged
merged 1 commit into from

3 participants

@cgohlke

No description provided.

@pelson
Collaborator

Thanks @cgohlke.

@mdboom mdboom merged commit dc19faa into matplotlib:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 30, 2012
  1. @cgohlke
This page is out of date. Refresh to see the latest.
Showing with 14 additions and 10 deletions.
  1. +14 −10 examples/event_handling/test_mouseclicks.py
View
24 examples/event_handling/test_mouseclicks.py
@@ -1,4 +1,6 @@
#!/usr/bin/env python
+from __future__ import print_function
+
import matplotlib
#matplotlib.use("WxAgg")
#matplotlib.use("TkAgg")
@@ -9,23 +11,25 @@
#matplotlib.use("MacOSX")
import matplotlib.pyplot as plt
-#print "***** TESTING WITH BACKEND: %s"%matplotlib.get_backend() + " *****"
+#print("***** TESTING WITH BACKEND: %s"%matplotlib.get_backend() + " *****")
+
def OnClick(event):
- if event.dblclick:
- print "DBLCLICK",event
- else:
- print "DOWN ",event
+ if event.dblclick:
+ print("DBLCLICK", event)
+ else:
+ print("DOWN ", event)
+
def OnRelease(event):
- print "UP ",event
+ print("UP ", event)
fig = plt.gcf()
-cid_up = fig.canvas.mpl_connect('button_press_event',OnClick)
-cid_down = fig.canvas.mpl_connect('button_release_event',OnRelease)
+cid_up = fig.canvas.mpl_connect('button_press_event', OnClick)
+cid_down = fig.canvas.mpl_connect('button_release_event', OnRelease)
-plt.gca().text(0.5,0.5,"Click on the canvas to test mouse events.",ha="center",va="center")
+plt.gca().text(0.5, 0.5, "Click on the canvas to test mouse events.",
+ ha="center", va="center")
plt.show()
-
Something went wrong with that request. Please try again.