>>>>> "Tommy" == Tommy Grav <[EMAIL PROTECTED]> writes:

    Tommy> I have a program that uses matplotlib to plot two images.
    Tommy> figim24 = figure(figsize=(5,5)) figim70 =
    Tommy> figure(figsize=(5,5))

    Tommy> I want an event loop that will be able to register which of
    Tommy> the two figures I mouse click in. When I only had one
    Tommy> figure I used

    Tommy> figim24.canvas.mpl_connect("button_press_event",clicker)

    Tommy> but that obviously only register events in figim24. Can
    Tommy> anyone guide me in the right direction for doing this?

You can either register two different callbacks (func1 and func2
below) or you can register both figures to the same callback (funcboth
below) and check which figure generated the event by inspecting the
figure.inaxes.figure attribute.  The latter approach only works if you
click over an axes,

from pylab import figure, show

fig1 = figure()
fig2 = figure()

ax1 = fig1.add_subplot(111)
ax2 = fig2.add_subplot(111)

def func1(event):
    print 'func1'

def func2(event):
    print 'func2'

def funcboth(event):
    if event.inaxes is None: return
    if event.inaxes.figure==fig1:
        print 'funcboth: 1'
    elif event.inaxes.figure==fig2:
        print 'funcboth: 2'

fig1.canvas.mpl_connect('button_press_event', func1)
fig2.canvas.mpl_connect('button_press_event', func2)

fig1.canvas.mpl_connect('button_press_event', funcboth)
fig2.canvas.mpl_connect('button_press_event', funcboth)

show()

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to