#NEWLINE# @ larch . ValidateLarchPlugin #NEWLINE# def _getcursor( win = 1 , timeout = 30 , _larch = None , wxparent = None , size = None , **kws ) : #NEWLINE# #INDENT# 'get_cursor(win=1, timeout=30)\n\n    waits (up to timeout) for cursor click in selected plot window, and\n    returns x, y position of cursor.  On timeout, returns the last known\n    cursor position, or (None, None)\n\n    Note that _plotter.plotWIN_x and _plotter.plotWIN_y will be updated,\n    with each cursor click, and so can be used to read the last cursor\n    position without blocking.\n\n    For a more consistent programmatic approach, this routine can be called\n    with timeout <= 0 to read the most recently clicked cursor position.\n    ' #NEWLINE# plotter = _getDisplay ( wxparent = wxparent , win = win , size = size , _larch = _larch ) #NEWLINE# symtable = ensuremod ( _larch , MODNAME ) #NEWLINE# sentinal = ( '%s.plot%i_cursorflag' % ( MODNAME , win ) ) #NEWLINE# xsym = ( '%s.plot%i_x' % ( MODNAME , win ) ) #NEWLINE# ysym = ( '%s.plot%i_y' % ( MODNAME , win ) ) #NEWLINE# xval = symtable . get_symbol ( xsym , create = True ) #NEWLINE# yval = symtable . get_symbol ( ysym , create = True ) #NEWLINE# symtable . set_symbol ( sentinal , False ) #NEWLINE# def onChange( symbolname = None , **kws ) : #NEWLINE# #INDENT# symtable . set_symbol ( kws [ 'sentinal' ] , True ) #NEWLINE# #UNINDENT# symtable . add_callback ( xsym , onChange , kws = { #NEWLINE# #INDENT# 'sentinal' : sentinal , #NEWLINE# #UNINDENT# } ) #NEWLINE# t0 = time . time ( ) #NEWLINE# while ( ( time . time ( ) - t0 ) < timeout ) : #NEWLINE# #INDENT# wx_update ( _larch = _larch ) #NEWLINE# if symtable . get_symbol ( sentinal ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# #UNINDENT# symtable . del_symbol ( sentinal ) #NEWLINE# symtable . clear_callbacks ( xval ) #NEWLINE# return ( symtable . get_symbol ( xsym ) , symtable . get_symbol ( ysym ) )