
t,2Jc           @   sJ  d  d k  l Z d  d k Z d  d k Z d  d k Z d  d k Z d  d k l Z d  d k l Z l	 Z	 d  d k
 l Z l Z l Z l Z l Z l Z d  d k l Z d  d k l Z d  d k l Z d  d	 k l Z y d  d k Z Wn e j
 o e d
   n Xd Z d   Z e Z h e i i  e i! 6e i i" e i# 6e i i$ e i% 6e i i& e i' 6Z( d   Z) d   Z* e e* _+ d   Z, d   Z- d e i. e f d     YZ/ d e f d     YZ0 d e e i. f d     YZ1 y* e i2 e i3 i4 e i5 d d d   Wn" e i6 d e i7   d  n Xd d  Z9 d   Z: e0 Z; d S(   i(   t   divisionN(   t   verbose(   t   is_string_liket   onetrue(   t   RendererBaset   GraphicsContextBaset   FigureManagerBaset   FigureCanvasBaset   NavigationToolbar2t   cursors(   t   Gcf(   t   Figure(   t   MathTextParser(   t   SubplotTools)   Qt backend requires pyqt to be installed.s   0.9.1c           C   s   t  i d  i i S(   Ni   (   t   syst	   _getframet   f_codet   co_name(    (    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyt   fn_name   s    c          C   s?   t  i   o. t i   }  |  d j o |  i i   q; n d S(   s5   
    Is called after every pylab drawing command
    N(   t
   matplotlibt   is_interactiveR
   t
   get_activet   Nonet   canvast   draw(   t
   figManager(    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyt   draw_if_interactive!   s    c           C   sn   t  i i   oZ t o	 d GHn t  i d g  a t  i i t t  i d  t t  i d   t	 t
 _ n d S(   sI   
    Only one qApp can exist at a time, so check before creating one
    s   Starting up QApplicationt    s   lastWindowClosed()s   quit()N(   t   qtt   QApplicationt
   startingUpt   DEBUGt   qAppt   QObjectt   connectt   SIGNALt   SLOTt   Truet   _create_qAppt   qAppCreatedHere(    (    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyR&   *   s     	c          C   s}   x! t  i   D] }  |  i i   q Wt o	 d GHn t  i   } | d j o | i i   n t	 i
 o t i i   n d S(   si   
    Show all the figures and enter the qt main loop
    This should be the last line of your script
    s   Inside showN(   R
   t   get_all_fig_managerst   windowt   showR   R   R   R   R   R&   R'   R   R    t	   exec_loop(   t   managerR   (    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyR*   9   s      	
c         O   s@   | i  d t  } | | |   } t |  } t | |   } | S(   s.   
    Create a new figure manager instance
    t   FigureClass(   t   popR   t   FigureCanvasQTt   FigureManagerQT(   t   numt   argst   kwargsR-   t   thisFigR   R,   (    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyt   new_figure_managerK   s
    R/   c           B   s   e  Z h d  e i i 6d e i i 6d e i i 6Z h d d 6d d 6d d 6Z d   Z	 d   Z
 d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z e i i e _ d   Z e i i e _ RS(   t   controlt   shiftt   alti   i   i   i   c         C   s}   t  o d G| GHn t   t i i |  d  d  t i |  |  | |  _ |  i t	  |  i
   \ } } |  i | |  d  S(   Ns   FigureCanvasQt: s   QWidget figure(   R   R&   R   t   QWidgett   __init__R   R   t   figuret   setMouseTrackingR%   t   get_width_heightt   resize(   t   selfR;   t   wt   h(    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyR:   ]   s     	c         C   s   t  i |  |  d  S(   N(   R   t   enter_notify_event(   R?   t   event(    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyt
   enterEventi   s    c         C   s   t  i |  |  d  S(   N(   R   t   leave_notify_event(   R?   RC   (    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyt
   leaveEventl   s    c         C   sx   | i    i   } |  i i i | i    i   } |  i | i   } t i	 |  | | |  t
 o d G| i   GHn d  S(   Ns   button pressed:(   t   post   xR;   t   bboxt   heightt   yt   buttondt   buttonR   t   button_press_eventR   (   R?   RC   RH   RK   RM   (    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyt   mousePressEvento   s     c         C   sL   | i    } |  i i i | i   } t i |  | |  t o	 d GHn d  S(   Ns
   mouse move(   RH   R;   RI   RJ   RK   R   t   motion_notify_eventR   (   R?   RC   RH   RK   (    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyt   mouseMoveEventw   s
     c         C   sb   | i    } |  i i i | i   } |  i | i   } t i |  | | |  t	 o	 d GHn d  S(   Ns   button released(
   RH   R;   RI   RJ   RK   RL   RM   R   t   button_release_eventR   (   R?   RC   RH   RK   RM   (    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyt   mouseReleaseEvent~   s     c         C   s7   |  i  |  } t i |  |  t o d G| GHn d  S(   Ns	   key press(   t   _get_keyR   t   key_press_eventR   (   R?   RC   t   key(    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyt   keyPressEvent   s     c         C   s7   |  i  |  } t i |  |  t o d G| GHn d  S(   Ns   key release(   RT   R   t   key_release_eventR   (   R?   RC   RV   (    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyt   keyReleaseEvent   s     c         C   s   t  o+ d | i   i   | i   i   f GHn t i i |  |  | i   i   } | i   i   } t  o d G| Gd G| Gd GHn |  i i } | | } | | } |  i i	 | |  |  i
   d  S(   Ns   resize (%d x %d)s   FigureCanvasQt.resizeEvent(t   ,t   )(   R   t   sizet   widthRJ   R   R9   t   resizeEventR;   t   dpit   set_size_inchesR   (   R?   RC   R@   RA   t   dpivalt   wincht   hinch(    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyR^      s     + 

c         C   sW   t  i i |  | |  |  i i } | | } | | } |  i i | |  |  i   d  S(   N(   R   R9   R>   R;   R_   R`   R   (   R?   R@   RA   t   pixelPerIncht   wIncht   hInch(    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyR>      s    

c         C   s"   |  i    \ } } t i | |  S(   N(   R=   R   t   QSize(   R?   R@   RA   (    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyt   sizeHint   s    c         C   s   t  i d d  S(   Ni
   (   R   Rg   (   R?   (    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyt   minumumSizeHint   s    c         C   sc   | i    d j  o | i   i   } n7 | i    |  i i j o |  i | i    } n d  } | S(   Ni   (   RV   t   textt   latin1t   keyvaldt   has_keyR   (   R?   RC   RV   (    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyRT      s    c         C   s   t  i i   d  S(   N(   R   R    t   processEvents(   R?   (    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyt   flush_events   s    c         C   s   t  i |  |  d  S(   N(   R   t   start_event_loop_default(   R?   t   timeout(    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyt   start_event_loop   s    c         C   s   t  i |   d  S(   N(   R   t   stop_event_loop_default(   R?   (    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyt   stop_event_loop   s    (   t   __name__t
   __module__R   t   Qtt   Key_Controlt	   Key_Shiftt   Key_AltRl   RL   R:   RD   RF   RO   RQ   RS   RW   RY   R^   R>   Rh   Ri   RT   Ro   Rr   R   Rp   t   __doc__Rt   Rs   (    (    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyR/   V   s,   													
			R0   c           B   sM   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 RS(   s   
    Public attributes

    canvas      : The FigureCanvas instance
    num         : The Figure number
    toolbar     : The qt.QToolBar
    window      : The qt.QMainWindow
    c            s  t  o d t   GHn t i   | |  |   _ t i d  d  t i i	    _
   i   i
 _ t i   i
  }   i i | t i d d     i i t i i    i i     i
 i d |  t   i
 _   i   i |    _ t i |    _   i i   i d    i o   i i   i d  n   i
 i |    i i   }   i i   }   i o |   i i   d 7} n   i
 i | |  t i    o   i
 i!   n   f d     i i" _!   f d   }   i i" i# |  d  S(   Ns   FigureManagerQT.%si    s	   Figure %di   i   c             s     i  i   S(    (   R)   R*   (   R2   (   R?   (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyt   <lambda>   s    c            s%     i  d  j o   i  i   n d  S(   N(   t   toolbarR   t   update(   t   fig(   R?   (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyt   notify_axes_change   s     ($   R   R   R   R:   R   R   t   QMainWindowR   Rw   t   WDestructiveCloseR)   t   _widgetCloseEventt
   closeEventR9   t   reparentt   QPointt   setFocusPolicyt
   ClickFocust   setFocust
   setCaptiont   Falset   _destroyingt   _get_toolbarR}   t   QVBoxLayoutt   layoutt	   addWidgett   setCentralWidgetR]   RJ   R>   R   R   R*   R;   t   add_axobserver(   R?   R   R1   t   centralWidgetR@   RA   R   (    (   R?   sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyR:      s8     	
	
c         C   s2   |  i  i o d  St |  i  _ t i |  i  d  S(   N(   R)   R   R%   R
   t   destroyR1   (   R?   (    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyt   _widgetclosed  s     c         C   s$   |  i    t i i |  i |  d  S(   N(   R   R   R9   R   R)   (   R?   RC   (    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyR   	  s    
c         C   sN   t  i d d j o	 d GHn. t  i d d j o t | |  } n d  } | S(   NR}   t   classics$   Classic toolbar is not yet supportedt   toolbar2(   R   t   rcParamst   NavigationToolbar2QTR   (   R?   R   t   parentR}   (    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyR     s    	c         C   s   |  i  i | |  d S(   s   set the canvas size in pixelsN(   R)   R>   (   R?   R]   RJ   (    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyR>     s    c         G   s]   |  i  i o d  St |  i  _ |  i o |  i i   n t o	 d GHn |  i  i t  d  S(   Ns   destroy figure manager(   R)   R   R%   R}   R   R   t   close(   R?   R2   (    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyR     s     
  	c         C   s   |  i  i |  d  S(   N(   R)   R   (   R?   t   title(    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyt   set_window_title#  s    (
   Ru   Rv   R{   R:   R   R   R   R>   R   R   (    (    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyR0      s   	5					R   c           B   s   e  Z d) d* d+ d- d. d/ d0 d1 d2 f	 Z d   Z d   Z d   Z d   Z d    Z d!   Z	 d"   Z
 d#   Z d$   Z d%   Z d&   Z d'   Z d(   Z RS(3   t   Homes   Reset original views   home.ppmt   homet   Backs   Back to  previous views   back.ppmt   backt   Forwards   Forward to next views   forward.ppmt   forwardt   Pans)   Pan axes with left mouse, zoom with rights   move.ppmt   pant   Zooms   Zoom to rectangles   zoom_to_rect.ppmt   zoomt   Subplotss   Configure subplotss   subplots.pngt   configure_subplotst   Saves   Save the figures   filesave.ppmt   save_figurec         C   s[   | |  _  h  |  _ t i i |  |  t i |   |  _ |  i i d  t i |  |  d  S(   Ni   (	   R   t   buttonsR   R9   R:   t   QHBoxLayoutR   t	   setMarginR   (   R?   R   R   (    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyR:   5  s    		c   
      C   s  t  i i t i d d  } x|  i D]\ } } } } | d  j o |  i i d  q& n t  i i | |  } t	 i
   } | i |  t	 i t	 i |  d |   } t	 i i | |  | |  i | <d }	 | i | i   |	 | i   |	  t	 i i | t	 i d  t |  |   |  i i |  q& W|  i d i t  |  i d i t  t	 i d |   |  _ |  i i t	 i i t	 i i  B |  i i! t	 i" t	 i" i# t	 i" i#   |  i i |  i d	  d  |  _$ d  S(
   Nt   datapatht   imagesi   t    i   s	   clicked()R   R   i   (%   t   ost   patht   joinR   R   t	   toolitemsR   R   t
   addSpacingR   t   QPixmapt   loadt   QPushButtont   QIconSett   QToolTipt   addR   t   setFixedSizeR]   RJ   R!   R"   R#   t   getattrR   t   setToggleButtonR%   t   QLabelt   locLabelt   setAlignmentRw   t
   AlignRightt   AlignVCentert   setSizePolicyt   QSizePolicyt   Ignoredt
   adj_window(
   R?   t   basedirRj   t   tooltip_textt
   image_filet   callbackt   fnamet   imageRM   t   margin(    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyt   _init_toolbarA  s2    
 $ c         C   sd   x] |  i  D]R \ } } } } | d  j	 o3 t i i |  i | t i d  t |  |   q
 q
 Wd  S(   Ns	   clicked()(   R   R   R   R!   t
   disconnectR   R#   R   (   R?   Rj   R   R   R   (    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyR   j  s    
 c         G   s(   |  i  d i t  t i |  |  d  S(   NR   (   R   t   setOnR   R   R   (   R?   R2   (    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyR   q  s    c         G   s(   |  i  d i t  t i |  |  d  S(   NR   (   R   R   R   R   R   (   R?   R2   (    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyR   u  s    c         C   s   |  i  i   d  S(   N(   R   R   (   R?   (    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyt   dynamic_updatey  s    c         C   s   |  i  i |  d  S(   N(   R   t   setText(   R?   t   s(    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyt   set_message|  s    c         C   sB   t  o d G| GHn t i i   t i i t i t |   d  S(   Ns
   Set cursor(   R   R   R   t   restoreOverrideCursort   setOverrideCursort   QCursort   cursord(   R?   t   cursor(    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyt
   set_cursor  s     c         C   s   |  i  i i i } | | } | | } t | |  } t | |  } g  }	 t | |  t | |  | | f D] }
 |	 t |
  qo ~	 } |  i  i |  d  S(   N(   R   R;   RI   RJ   t   abst   mint   intt   drawRectangle(   R?   RC   t   x0t   y0t   x1t   y1RJ   R@   RA   t   _[1]t   valt   rect(    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyt   draw_rubberband  s    

Ec   	      C   s  t  i d  d  t  i i  |  _ |  i } | i d  t d d	  } | i d d  t	 | i
 i  } t	 | i
 i  } |  i |  } t |  i i |  } t  i |  } | i | t  i d d   | i |  t  i |  } | i | d  | i | |  | i   | i   d  S(
   Ns   Subplot Configuration Toolt   figsizei   i   t   topg?i    i   (   i   i   (   R   R   R   Rw   R   R   R   R   t   subplots_adjustR   RI   R]   RJ   t   _get_canvasR   R   R;   R9   R   R   R   R   R   R>   R   R*   (	   R?   t   wint   toolfigR@   RA   R   t   toolR   R   (    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyR     s"    	
c         C   s
   t  |  S(   N(   R/   (   R?   R   (    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyR     s    c      	   C   sb  |  i  i   } | i   } | i   |  i  i   } d | } g  } d  } xv | D]n \ } } d i g  }	 | D] }
 |	 d |
 qn ~	  } d | | f } | | j o
 | } n | i |  qQ Wd i |  } t i	 i
 | | |  d d |  } | od y |  i  i t |   Wq^t j
 o7 } t i i |  d t |  t i i t i i  q^Xn d  S(	   Ns   image.R   s   *.%ss   %s (%s)s   ;;s
   Save images   Choose a filename to save tos   Error saving file(   R   t   get_supported_filetypes_groupedt   itemst   sortt   get_default_filetypeR   R   t   appendR   t   QFileDialogt   getSaveFileNamet   print_figuret   unicodet	   Exceptiont   QMessageBoxt   criticalt   strt   Okt   NoButton(   R?   t	   filetypest   sorted_filetypest   default_filetypet   startt   filterst   selectedFiltert   namet   extsR   t   extt	   exts_listt   filterR   t   e(    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyR     s2    

 .
			c         C   s`   |  i  i d j } |  i  i t |  i  i  d j  } |  i d i |  |  i d i |  d  S(   Ni    i   R   R   (   t   _viewst   _post   lent	   _elementsR   t
   setEnabled(   R?   t   canBackwardt
   canForward(    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyt   set_history_buttons  s    "(   R   s   Reset original views   home.ppmR   (   s   Backs   Back to  previous views   back.ppmR   (   s   Forwards   Forward to next views   forward.ppmR   N(   NNNN(   s   Pans)   Pan axes with left mouse, zoom with rights   move.ppms   pan(   s   Zooms   Zoom to rectangles   zoom_to_rect.ppms   zoom(   NNNN(   R   s   Configure subplotss   subplots.pngs   configure_subplots(   R   s   Save the figures   filesave.ppms   save_figure(   Ru   Rv   R   R   R:   R   R   R   R   R   R   R   R   R   R   R   R  (    (    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyR   &  s,   			)										R   R   s   matplotlib.svgs"   Could not load matplotlib icon: %si   c         C   sL   t  |   p d i t t |    }  n t i i d  d |  t i i  d  S(   NRZ   t
   Matplotlib(	   R   R   t   mapR   R   R   t   warningR   R   (   t   msgR   (    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyt   error_msg_qt  s    c         C   s   d } t  | d  o! | i d j o | i d } n t  | d  o! | i d j o | | i 7} n | t |  7} t |  o t |  n d S(   s@   Handle uncaught exceptions
    It does not catch SystemExit
    R   t   filenames   : t   strerrorN(   t   hasattrR  R   R  R   R  R  (   t   typet   valuet   tbR  (    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyt   exception_handler  s       (<   t
   __future__R    t   mathR   R   R   R   t   matplotlib.cbookR   R   t   matplotlib.backend_basesR   R   R   R   R   R	   t   matplotlib._pylab_helpersR
   t   matplotlib.figureR   t   matplotlib.mathtextR   t   matplotlib.widgetsR   R   t   ImportErrort   backend_versionR   R   R   Rw   t   PointingHandCursort   MOVEt
   WaitCursort   HANDt   ArrowCursort   POINTERt   CrossCursort   SELECT_REGIONR   R   R&   R'   R*   R5   R9   R/   R0   R   t!   window_set_default_icon_from_fileR   R   R   t   reportt   exc_infoR   R  R  t   FigureManager(    (    (    sN   C:\graphics\Tools\Python26\Lib\site-packages\matplotlib\backends\backend_qt.pyt   <module>   sN   .							oa$	