
    h                     h    S r SSKrSSKJr   " S S5      r\R
                  " \R                  5        g)z*
Manage figures for the pyplot interface.
    N)OrderedDictc                       \ rS rSrSr\" 5       r\S 5       r\S 5       r	\S 5       r
\S 5       r\S 5       r\S 5       r\S	 5       r\S
 5       r\S 5       r\S 5       r\SS j5       rSrg)Gcf	   a  
Singleton to maintain the relation between figures and their managers, and
keep track of and "active" figure and manager.

The canvas of a figure created through pyplot is associated with a figure
manager, which handles the interaction between the figure and the backend.
pyplot keeps track of figure managers using an identifier, the "figure
number" or "manager number" (which can actually be any hashable value);
this number is available as the :attr:`number` attribute of the manager.

This class is never instantiated; it consists of an `OrderedDict` mapping
figure/manager numbers to managers, and a set of class methods that
manipulate this `OrderedDict`.

Attributes
----------
figs : OrderedDict
    `OrderedDict` mapping numbers to managers; the active manager is at the
    end.
c                 f    U R                   R                  US5      nUb  U R                  U5        U$ )z`
If manager number *num* exists, make it the active one and return it;
otherwise return *None*.
N)figsget
set_activeclsnummanagers      K/var/www/html/env/lib/python3.13/site-packages/matplotlib/_pylab_helpers.pyget_fig_managerGcf.get_fig_manager!   s/     ((,,sD)NN7#    c                   ^ [        U4S jS 5       5      (       aP  TnU R                  R                  UR                  5      UL a%  U R                  R	                  UR                  5        O U R                  R	                  T5      n[        US5      (       a%  UR                  R                  UR                  5        UR                  5         g! [
         a     gf = f)a  
Destroy manager *num* -- either a manager instance or a manager number.

In the interactive backends, this is bound to the window "destroy" and
"delete" events.

It is recommended to pass a manager instance, to avoid confusion when
two managers share the same number.
c              3   <   >#    U  H  n[        TU5      v   M     g 7fN)hasattr).0attrr   s     r   	<genexpr>Gcf.destroy.<locals>.<genexpr>7   s     A.@dwsD!!.@s   )r   destroyN_cidgcf)allr   r	   r   popKeyErrorr   canvasmpl_disconnectr   r   r   s    ` r   r   Gcf.destroy,   s     A.@AAAGxx||GKK(G3W[[)((,,s+ 7I&&NN))'//:	  s   -C 
CCc                    ^ [        U4S jU R                  R                  5        5       S5      nUb  U R                  U5        gg)zDestroy figure *fig*.c              3   t   >#    U  H-  nUR                   R                  T:X  d  M  UR                  v   M/     g 7fr   )r    figurer   )r   r   figs     r   r   "Gcf.destroy_fig.<locals>.<genexpr>G   s0      5/@G~~,,3  GKK/@s   88N)nextr   valuesr   )r   r&   r   s    ` r   destroy_figGcf.destroy_figD   s?      5sxx/@ 56:<?KK r   c                     [        U R                  R                  5       5       H8  nUR                  R	                  UR
                  5        UR                  5         M:     U R                  R                  5         g)zDestroy all figures.N)listr   r)   r    r!   r   r   clearr   r   s     r   destroy_allGcf.destroy_allL   sN     CHHOO-.GNN))'//:OO / 	r   c                     XR                   ;   $ )z*Return whether figure number *num* exists.)r   )r   r   s     r   
has_fignumGcf.has_fignumT   s     hhr   c                 H    [        U R                  R                  5       5      $ )z!Return a list of figure managers.)r-   r   r)   r   s    r   get_all_fig_managersGcf.get_all_fig_managersY   s     CHHOO%&&r   c                 ,    [        U R                  5      $ )z+Return the number of figures being managed.)lenr   r6   s    r   get_num_fig_managersGcf.get_num_fig_managers^   s     388}r   c                     U R                   (       a,  [        [        U R                   R                  5       5      5      $ S$ )z<Return the active manager, or *None* if there is no manager.N)r   r(   reversedr)   r6   s    r   
get_activeGcf.get_activec   s*     58HHtHSXX__./0F$Fr   c                 6  ^ ^ [        TS5      (       d&  TR                  R                  SU U4S j5      Tl        TR                  R                  nTR
                  Ul        UR                  5       nU(       a  TR                  U5        T R                  T5        g)z;Adopt *manager* into pyplot and make it the active manager.r   button_press_eventc                 &   > TR                  T5      $ r   )r
   )eventr   r   s    r   <lambda>-Gcf._set_new_active_manager.<locals>.<lambda>m   s    CNN74Kr   N)
r   r    mpl_connectr   r%   r   _number	get_labelset_window_titler
   )r   r   r&   labels   ``  r   _set_new_active_managerGcf._set_new_active_managerh   sq     w	**%nn88$&KMGOnn##kk$$U+wr   c                 ~    XR                   UR                  '   U R                   R                  UR                  5        g)z"Make *manager* the active manager.N)r   r   move_to_endr/   s     r   r
   Gcf.set_activeu   s*     !(W[[)r   c                     U R                  5        HK  nU(       d'  UR                  R                  R                  (       d  M1  UR                  R	                  5         MM     g)zP
Redraw all stale managed figures, or, if *force* is True, all managed
figures.
N)r7   r    r%   stale	draw_idle)r   forcer   s      r   draw_allGcf.draw_all{   s?     //1G--333((* 2r    N)F)__name__
__module____qualname____firstlineno____doc__r   r   classmethodr   r   r*   r0   r3   r7   r;   r?   rL   r
   rU   __static_attributes__rW   r   r   r   r   	   s    * =D   .       ' '   G G 
  
  * *
 + +r   r   )r\   atexitcollectionsr   r   registerr0   rW   r   r   <module>rb      s1     #z+ z+z   r   