hi there,

i'm writing a linear step by step scripts and i'd like to use
matplotlibs interactive features as a step to load up some data, the
user to identify a point, the plot window closed and the point to be
returned to my script for further processing.

i assumed that waiting for pylab.show() to return would halt my script
until the figure was dismissed however this only works on the first
run of my script i.e.

In [1]: run z:/archive/scripts/TCD_import_probe_data
8.13378191174e-007 0.00635162601626

In [2]: run z:/archive/scripts/TCD_import_probe_data
None None

In the second invocation the figure was displayed but the script
carried on running before the figure was dismissed.

Running %reset between invocations has no effect.

Here is the crux of the script,

class SetOrigin(object):
  """
  callback functor for origin placement
  """
  def __init__(self, x=None, y=None):
    self.x = x
    self.y = y
    if x and y:
      self.set = True
    else:
      self.set = False
  def __call__(self, event):
    if event.inaxes:
      self.x = event.xdata
      self.y = event.ydata
      self.set = True

pylab.plot(time, voltage)
pylab.title('Click cursor on origin ...')
cursor = Cursor(pylab.gca(), useblit=True, color='#ff0000', linewidth=1)

origin = SetOrigin()
pylab.connect('button_press_event', origin)

foo = pylab.show()

print origin.x, origin.y

pylab.show()

What am i doing wrong?

This happens in plain iPython shell and pysh (scipy shell has
difficulty loading the script 'Original traceback cannot be
reconstructed...')

brendan

-------------------------------------------------------------------------
SF.Net email is sponsored by: 
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to