Skip to content

Commit 3ce0e06

Browse files
committed
added the test_mouseclicks.py script in the examples/event_handling directory
1 parent 2c51a33 commit 3ce0e06

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env python
2+
import matplotlib
3+
#matplotlib.use("WxAgg")
4+
#matplotlib.use("TkAgg")
5+
matplotlib.use("GTKAgg")
6+
#matplotlib.use("QtAgg")
7+
#matplotlib.use("Qt4Agg")
8+
import matplotlib.pyplot as plt
9+
import math
10+
import numpy
11+
12+
print "***** TESTING WITH BACKEND: %s"%matplotlib.get_backend() + " *****"
13+
14+
def OnClick(event):
15+
if event.dblclick:
16+
print "DBLCLICK",event
17+
else:
18+
print "DOWN",event
19+
20+
def OnRelease(event):
21+
print "UP",event
22+
23+
24+
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)
27+
28+
t = numpy.arange(0.0,3.0,0.01)
29+
s = numpy.sin(2*math.pi*t)
30+
plt.plot(t,s)
31+
32+
plt.show()
33+

0 commit comments

Comments
 (0)