
    +d                     n    d dl mZ d dlZddlmZmZmZ ddlm	Z	 ddl
mZ ddlmZ  G d	 d
e          ZdS )    )partialN   )	MAX_WIDTHBaseenable_widget   )CatAdder)Search)CatSelectorc                        e Zd ZdZd fd	Zd Zej        j        d             Zd Z	d Z
ed             Zd	 Zd
 Zed             Z xZS )CatGUIaD  
    Top level GUI panel that contains controls and all visible sub-panels

    This class is responsible for coordinating the inputs and outputs
    of various sup-panels and their effects on each other.

    Parameters
    ----------
    cats: list of catalogs
        catalogs used to initalize the select
    done_callback: func, opt
        called when the object's main job has completed. In this case,
        selecting catalog(s).

    Attributes
    ----------
    children: list of panel objects
        children that will be used to populate the panel when visible
    panel: panel layout object
        instance of a panel layout (row or column) that contains children
        when visible
    watchers: list of param watchers
        watchers that are set on children - cleaned up when visible
        is set to false.
    Nc           
         || _         t          j        ddt                    | _        |pd | _        t          j                            dddd          | _        t          j        	                    d	d
d          | _
        t          j                            ddd
d          | _        | j        | j
        | j        g| _        t          j        dd          | _        t          | j         | j                  | _        t%          | j        j        | j        j        t+          t,          | j        d                    | _        t/          | j        | j        j        | j        j        t+          t,          | j        d                    | _        | j        j        | j        | j        j        | j        j        g| _         t7                      j        di | d S )NCatalogsmax)namewidth_policy	max_widthc                     | S )N )xs    <lib/python3.11/site-packages/intake/interface/catalog/gui.py<lambda>z!CatGUI.__init__.<locals>.<lambda>/   s         u   ＋F2   )r   valuedisabledwidthu   ―T)r   r   r   u   🔍Controlsr   )r   margin)catsdone_callbackr   )r!   visiblevisible_callback)r    r!   r"   r#   r   )_catspnColumnr   panelr!   widgetsToggle
add_widgetButtonremove_widgetsearch_widgetcontrolsRowcontrol_panelr   callbackselectr	   addr   r   setattrr
   r    searchchildrensuper__init__)selfr    r!   kwargs	__class__s       r   r8   zCatGUI.__init__,   s   
YJUiXXX
*;{{*++ee[]+^^Z..EDPR.SSZ..F%RV^`.aa O

  VA>>>!tzOOO$+/4?CXkrsz  }A  }L  NU  lV  lV  W  W  W$+/4CUC[nuv}  @D  @R  T[  o\  o\
 
 

 KKHN	
 	""6"""""r   c                     | j                             | j        d          | j        j                            | j        d          | j        j                            | j        j	        d          g| _
        d S )Nr"   r   r   clicks)r*   linkr3   r-   paramwatchon_click_search_widgetr,   r2   remove_selectedwatchersr9   s    r   setupzCatGUI.setupM   sc    O   ;;$**4+FPP$**4;+FQQ
r   c                 ^   || _         |r|t          | j        j                  dk    r_|                                  d| j        _        | j                            | j	                   | j                            | j
                   n|st          | j        j                  dk    rj|                                  d| j        _        | j                                         d| j        _        d| j        _        | j                                         | j        r|                     |           dS dS )zCWhen visible changed, do setup or unwatch and call visible_callbackr   TFN)_visiblelen_panelobjectsrF   r2   r"   r0   extendr.   r6   unwatchclearr5   r3   r#   )r9   r"   s     r   r"   zCatGUI.visibleT   s      	 s4;.//14 	 JJLLL"&DK%%dm444Kt}---- 	 S!4559 	 LLNNN"'DK$$&&&"'DK$DHK  	+!!'*****	+ 	+r   c                     t          |          }|sd| j        _        t          | j        |           t          | j        |           | j        r|                     |           dS dS )zeWhen a catalog is selected, enable widgets that depend on that condition
        and do done_callbackFN)boolr5   r"   r   r-   r,   r!   )r9   r    enables      r   r1   zCatGUI.callbacki   sv     d 	("'DKd(&111d(&111 	%t$$$$$	% 	%r   c                     | j         | j        _         |j        | j        _        | j        j        rE| j        j                            | j        j                            | j        d                     dS dS )zEWhen the search control is toggled, set visibility and hand down catsr    r=   N)	r    r5   newr"   rD   appendr2   widgetr?   )r9   events     r   rB   zCatGUI.on_click_search_widgetv   sn    9#i; 	\K ''(:(?(?SY(?(Z(Z[[[[[	\ 	\r   c                     | j         j        S )z,Cats that have been selected from the select)r2   selectedrE   s    r   r    zCatGUI.cats}   s     {##r   c                     | j         | j                                        | j                                        | j                            d          dS )z)Serialize the current state of the objectF)include_cats)r"   r2   r3   r5   )r"   r2   __getstate__r3   r5   rE   s    r   r[   zCatGUI.__getstate__   sP     |k..008((**k..E.BB	
 
 	
r   c                 
   |                     dd          | _        | j        r`| j                            |d                    | j                            |d                    | j                            |d                    | S )zSet the current state of the object from the serialized version.
        Works inplace. See ``__getstate__`` to get serialized version and
        ``from_state`` to create a new object.r"   Tr2   r3   r5   )getr"   r2   __setstate__r3   r5   )r9   states     r   r^   zCatGUI.__setstate__   sv     yyD11< 	6K$$U8_555H!!%,///K$$U8_555r   c                 @     | g                                |          S )zCreate a new object from a serialized verion of another one.

        Example
        -------
        original = CatGUI()
        copy = CatGUI.from_state(original.__getstate__())
        )r    )r^   )clsr_   s     r   
from_statezCatGUI.from_state   s"     s|||((///r   )NN)__name__
__module____qualname____doc__r8   rF   r   r"   setterr1   rB   propertyr    r[   r^   classmethodrb   __classcell__)r;   s   @r   r   r      s         4# # # # # #B
 
 
 
\+ + +(% % %\ \ \ $ $ X$
 
 
	 	 	 0 0 [0 0 0 0 0r   r   )	functoolsr   r'   r%   baser   r   r   r3   r	   r5   r
   r2   r   r   r   r   r   <module>rm      s              1 1 1 1 1 1 1 1 1 1                  N0 N0 N0 N0 N0T N0 N0 N0 N0 N0r   