3
Æ½ hå  ã               @   s0   d Z ddljZddlmZ dd„ Zd	dd„ZdS )
z¢
========================
Widget testing utilities
========================
Functions that are useful for testing widgets.
See also matplotlib.tests.test_widgets
é    N)Úmockc              C   s>   t jddƒ\} }|jddgddgƒ |jdƒ |jjjƒ  |S )z!Creates plot and returns its axesé   r   éÈ   g      ð?)ÚpltZsubplotsZplotZ
set_aspectÚfigureÚcanvasZdraw)ZfigÚax© r	   ú@/tmp/pip-build-7iwl8md4/matplotlib/matplotlib/testing/widgets.pyÚget_ax   s
    
r   r   c       
      C   s„   t jƒ }||_| j}|jj||f||fgƒd \|_|_|| |_|_	||_
|jj|_||_||_d|_d|_t| |ƒ}	|	|ƒ dS )a4  
    Trigger an event

    Parameters
    ----------
    tool : matplotlib.widgets.RectangleSelector
    etype
        the event to trigger
    xdata : int
        x coord of mouse in data coords
    ydata : int
        y coord of mouse in data coords
    button : int or str
        button pressed None, 1, 2, 3, 'up', 'down' (up and down are used
        for scroll events)
    key
        the key depressed when the mouse event triggered (see
        :class:`KeyEvent`)
    step : int
        number of scroll steps (positive for 'up', negative for 'down')
    r   NZCustom)r   ZMockÚbuttonr   Z	transDataZ	transformÚxÚyÚxdataÚydataZinaxesr   r   ÚkeyÚstepZguiEventÚnameÚgetattr)
ZtoolÚetyper   r   r   r   r   Úeventr   Úfuncr	   r	   r
   Údo_event   s    

r   )r   r   r   Nr   )Ú__doc__Zmatplotlib.pyplotZpyplotr   Zunittestr   r   r   r	   r	   r	   r
   Ú<module>   s   
	