
    "e                         d dl Z d dlmZ ddddddd	d
Z e eej                         ej                                     Zdxed<   ed<   ded<   ded<   d Z	d Z
d Zd Zd Zd Zd Zd Zd Zy)    N)	pydev_logTkAggGTKAggWXAggQtAggQt4AggQt5AggMacOSX)tkgtkwxqtqt4qt5osxr   GTKGTKCairor   WXr   CocoaAggc                 
   ddl m}  |       r	 ddlm}  ||        | S | dvr"t        j
                  j                  d| z         | S #  t        j
                  j                  d| z         t        j                          Y | S xY w)Nr   )versionok_for_gui)
enable_guiz5Failed to enable GUI event loop integration for '%s'
)none NzSDebug console: Python version does not support GUI event loop integration for '%s'
)	 _pydev_bundle.pydev_versioncheckr   pydev_ipython.inputhookr   sysstderrwriter   	exception)guinamer   r   s      ?/usr/lib/python3/dist-packages/pydev_ipython/matplotlibtools.pydo_enable_guir#      s~    B	":w N	 
*	*

oryyzN	"JJUX__`!
 Ns   A 8Bc                  z    t         j                  d   } | j                  d   }t        j	                  |d      }||fS )zReturn the gui and mpl backend.
matplotlibbackendN)r   modulesrcParamsbackend2guiget)r%   r&   guis      r"   find_gui_and_backendr,   )   s<    \*J!!),G //'4
(C<    c                 l    t         j                  d   }ddlm}m} | |v ry| |v ry|j                         S )z! Check if backend is interactive r%   r   )interactive_bknon_interactive_bkTF)r   r'   matplotlib.rcsetupr/   r0   is_interactive)r&   r%   r/   r0   s       r"   is_interactive_backendr3   4   s9    \*JE. 	&	&((**r-   c                 j     t         j                  d    fd}j                  _        |_        y)! Patch matplotlib function 'use' r%   c                  T     j                   | i | t               \  }} |       y )N)real_user,   )argskwargsr+   r&   enable_gui_functionr%   s       r"   patched_usezpatch_use.<locals>.patched_useD   s,    
T,V,+-WC r-   N)r   r'   user7   )r:   r;   r%   s   ` @r"   	patch_user=   @   s+    \*J!
 %..J JNr-   c                  f    t         j                  d   fd} j                  _        | _        y)r5   r%   c                  "     j                   d   S )Ninteractive)r(   )r%   s   r"   patched_is_interactivez4patch_is_interactive.<locals>.patched_is_interactiveQ   s    ""=11r-   N)r   r'   r2   real_is_interactive)rA   r%   s    @r"   patch_is_interactiverC   M   s.    \*J2 &0%>%>J" 6Jr-   c                    t         j                  d   }t               \  }}t        |      }|rL | |       |j	                         s"t         j
                  j                  d|z         |j                  d       nC|j	                         r"t         j
                  j                  d|z         |j                  d       t        |        t                y)zSet interactive to True for interactive backends.
    enable_gui_function - Function which enables gui, should be run in the main thread.
    r%   z@Backend %s is interactive backend. Turning interactive mode on.
TzEBackend %s is non-interactive backend. Turning interactive mode off.
FN)
r   r'   r,   r3   r2   stdoutr   r@   r=   rC   )r:   r%   r+   r&   r2   s        r"   activate_matplotlibrF   X   s     \*J')LC+G4NC ((*JJ`cjjkt$$$&JJehoopu%!"r-   c                 b     t         d      r S  fdd_         j                  _        S )a%  Wrap a function to detect and flag when it gets called.

    This is a decorator which takes a function and wraps it in a function with
    a 'called' attribute. wrapper.called is initialized to False.

    The wrapper.called attribute is set to False right before each call to the
    wrapped function, so if the call fails it remains False.  After the call
    completes, wrapper.called is set to True and the output is returned.

    Testing for truth in wrapper.called allows you to determine if a call to
    func() was attempted and succeeded.calledc                  4    d_          | i |}d_         |S )NFT)rH   )r8   kwoutfuncwrappers      r"   rM   zflag_calls.<locals>.wrapper}   s%    DB
r-   F)hasattrrH   __doc__)rL   rM   s   `@r"   
flag_callsrP   l   s2     tX GNllGONr-   c                      t         j                  d   } d| j                  _        t	        | j
                        | _        y )NpylabFr   r'   show	_needmainrP   draw_if_interactive)rR   s    r"   activate_pylabrW      s1    KK E EJJ !+5+D+D EEr-   c                      t         j                  d   } d| j                  _        t	        | j
                        | _        y )Nzmatplotlib.pyplotFrS   )pyplots    r"   activate_pyplotrZ      s2    [[,-F!FKK ",F,F,F!GFr-   )r   _pydev_bundler   backendsdictzipvalueskeysr)   r#   r,   r3   r=   rC   rF   rP   rW   rZ    r-   r"   <module>rb      s    
 # 3x((--/:; 05 4E [,D J  	+
!7(8FHr-   