o
    tff                     @   s   d Z ddlmZ ddlmZ ddlmZ ddlmZm	Z	m
Z
mZmZmZ ddlmZ ddlmZmZmZ dd
dZG dd deeZeG dd deZeG dd deZeG dd deZd	S )zpSelectionContainer class.

Represents a multipage container that can be used to group other widgets into
pages.
   )Box)register)
CoreWidget    )UnicodeDictCInt
TraitErrorvalidateobserve)
TypedTuple)chainrepeatisliceNc                 C   s   t t| t||S )zkReturns the sequence elements and then returns None up to the given size (or indefinitely if size is None).)r   r   r   )iterablepaddinglength r   u/var/www/html/software/conda/envs/catlas/lib/python3.10/site-packages/ipywidgets/widgets/widget_selectioncontainer.pypad   s   r   c                   @   s   e Zd ZdZee ddjddZeddddjddZ	e
d	d
d Ze
ddd Zeddd Zdd Zdd Zdd Zdd ZdS )_SelectionContainerz2Base class used to display multiple child widgets.zTitles of the pages)ZtraithelpTsynczThe index of the selected page. This is either an integer selecting a particular sub-widget, or None to have no widgets selected.N)r   
allow_nonedefault_valueselected_indexc                 C   sB   |j d u sd|j   krt| jk r|j S  td|j S td)Nr   z&Invalid selection: index out of bounds)valuelenchildrenr	   selfZproposalr   r   r   _validated_index   s   $z$_SelectionContainer._validated_indextitlesc                 C   s   t t|jdt| jS )N )tupler   r   r   r   r    r   r   r   _validate_titles&   s   z$_SelectionContainer._validate_titlesr   c                 C   s   |    |   d S N)_reset_selected_index_reset_titles)r!   Zchanger   r   r   _observe_children*   s   z%_SelectionContainer._observe_childrenc                 C   s,   | j d urt| j| j k rd | _ d S d S d S r'   )r   r   r   r!   r   r   r   r(   /   s   
z)_SelectionContainer._reset_selected_indexc                 C   s(   t | jt | jkrt| j| _d S d S r'   )r   r#   r   r%   r+   r   r   r   r)   3   s   z!_SelectionContainer._reset_titlesc                 C   s,   t | j}|du rd}|||< t|| _dS )zSets the title of a container page.
        Parameters
        ----------
        index : int
            Index of the container page
        title : unicode
            New title
        Nr$   )listr#   r%   )r!   indextitler#   r   r   r   	set_title8   s
   
	z_SelectionContainer.set_titlec                 C   s
   | j | S )zGets the title of a container page.
        Parameters
        ----------
        index : int
            Index of the container page
        )r#   )r!   r-   r   r   r   	get_titleH   s   
z_SelectionContainer.get_title)__name__
__module____qualname____doc__r   r   tagr#   r   r   r
   r"   r&   r   r*   r(   r)   r/   r0   r   r   r   r   r      s(    


r   c                   @   0   e Zd ZdZedjddZedjddZdS )	Accordionz4Displays children each on a separate accordion page.ZAccordionViewTr   ZAccordionModelNr1   r2   r3   r4   r   r5   
_view_name_model_namer   r   r   r   r7   Q       r7   c                       sJ   e Zd ZdZedjddZedjddZd fdd	Zd	d
 Z	  Z
S )Tabz3Displays children each on a separate accordion tab.ZTabViewTr   ZTabModelr   c                    s6   t |dkrd|vrd|d< t jdd|i| d S )Nr   r   r   r   )r   super__init__)r!   r   kwargs	__class__r   r   r>   ^   s   zTab.__init__c                 C   sL   t | j}|dkrd | _d S | jd krd| _d S || jk r$|d | _d S d S )Nr   r   )r   r   r   )r!   Znum_childrenr   r   r   r(   c   s   




zTab._reset_selected_index)r   )r1   r2   r3   r4   r   r5   r9   r:   r>   r(   __classcell__r   r   r@   r   r<   X   s    r<   c                   @   r6   )Stackz!Displays only the selected child.Z	StackViewTr   Z
StackModelNr8   r   r   r   r   rC   t   r;   rC   )NN)r4   Z
widget_boxr   Zwidgetr   Zwidget_corer   Z	traitletsr   r   r   r	   r
   r   Ztrait_typesr   	itertoolsr   r   r   r   r   r7   r<   rC   r   r   r   r   <module>   s    
;