B
    p[Y
                 @   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 ddlmZ G dd	 d	e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)unicode_typec                   sf   e Zd ZdZeddjddZedddjddZe	dd	d
 Z
dd Zdd Z fddZ  ZS )_SelectionContainerz2Base class used to display multiple child widgets.zTitles of the pages)helpT)synczThe index of the selected page. This is either an integer selecting a particular sub-widget, or None to have no widgets selected.)r   Z
allow_noneselected_indexc             C   s<   |j d ks*d|j   kr&t| jk r0n n|j S tdd S )Nr   z&Invalid selection: index out of bounds)valuelenZchildrenr	   )selfZproposal r   Klib/python3.7/site-packages/ipywidgets/widgets/widget_selectioncontainer.py_validated_index   s    *z$_SelectionContainer._validated_indexc             C   s$   t t|}|| j|< | d dS )zSets the title of a container page.

        Parameters
        ----------
        index : int
            Index of the container page
        title : unicode
            New title
        _titlesN)r   intr   Z
send_state)r   indextitler   r   r   	set_title!   s    
z_SelectionContainer.set_titlec             C   s(   t t|}|| jkr | j| S dS dS )zGets the title of a container pages.

        Parameters
        ----------
        index : int
            Index of the container page
        N)r   r   r   )r   r   r   r   r   	get_title0   s    	

z_SelectionContainer.get_titlec             #   s.   xt t|  D ]
}|V  qW | jr*dV  d S )Nr   )superr   
_repr_keysr   )r   key)	__class__r   r   r   ?   s    
z_SelectionContainer._repr_keys)__name__
__module____qualname____doc__r   tagr   r   r   r
   r   r   r   r   __classcell__r   r   )r   r   r      s   r   c               @   s0   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AccordionViewT)r   ZAccordionModelN)r    r!   r"   r#   r   r$   
_view_name_model_namer   r   r   r   r&   G   s   r&   c               @   s0   e Zd ZdZedjddZedjddZdS )Tabz3Displays children each on a separate accordion tab.ZTabViewT)r   ZTabModelN)r    r!   r"   r#   r   r$   r'   r(   r   r   r   r   r)   N   s   r)   N)r#   Z
widget_boxr   Zwidgetr   Zwidget_corer   Z	traitletsr   r   r   r	   r
   Zipython_genutils.py3compatr   r   r&   r)   r   r   r   r   <module>   s   6