
    Xhf                         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
Z G d dee      Ze G d de             Ze G d de             Ze G d de             Zy	)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                 @    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lengths      `/var/www/html/myenv/lib/python3.12/site-packages/ipywidgets/widgets/widget_selectioncontainer.pypadr      s    %&/2F;;    c                       e Zd ZdZ e e       d      j                  d      Z eddd      j                  d      Z	 e
d	      d
        Z e
d      d        Z ed      d        Zd Zd Zd Zd Zy)_SelectionContainerz2Base class used to display multiple child widgets.zTitles of the pages)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                     |j                   @d|j                   cx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
   selfproposals     r   _validated_indexz$_SelectionContainer._validated_index   s[    >>!Q(..%M3t}};M%M>>! &N EFF >>!EFFr   titlesc           	      h    t        t        |j                  dt        | j                                    S )N )tupler   r"   r#   r$   r%   s     r   _validate_titlesz$_SelectionContainer._validate_titles&   s#    SS-?@AAr   r$   c                 D    | j                          | j                          y N)_reset_selected_index_reset_titles)r&   changes     r   _observe_childrenz%_SelectionContainer._observe_children*   s    ""$r   c                 r    | j                   +t        | j                        | j                   k  rd | _         y y y r/   )r    r#   r$   r&   s    r   r0   z)_SelectionContainer._reset_selected_index/   s5    *s4==/ADDWDW/W"&D 0X*r   c                     t        | j                        t        | j                        k7  rt        | j                        | _        y y r/   )r#   r)   r$   r,   r5   s    r   r1   z!_SelectionContainer._reset_titles3   s1    t{{s4==11,DK 2r   c                 `    t        | j                        }|d}|||<   t        |      | _        y)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)   s       r   	set_titlez_SelectionContainer.set_title8   s0     dkk"=EuFmr   c                      | j                   |   S )zGets the title of a container page.
        Parameters
        ----------
        index : int
            Index of the container page
        )r)   )r&   r9   s     r   	get_titlez_SelectionContainer.get_titleH   s     {{5!!r   )__name__
__module____qualname____doc__r   r   tagr)   r	   r    r   r(   r-   r   r3   r0   r1   r;   r=    r   r   r   r      s    <gi.CDHHdHSF U 
ctcn	  G  G hB B Z '-
$ "r   r   c                   p    e Zd ZdZ ed      j                  d      Z ed      j                  d      Zy)	Accordionz4Displays children each on a separate accordion page.AccordionViewTr   AccordionModelNr>   r?   r@   rA   r   rB   
_view_name_model_namerC   r   r   rE   rE   Q   s6    >)--4-8J*+//T/:Kr   rE   c                        e Zd ZdZ ed      j                  d      Z ed      j                  d      Zd fd	Zd Z	 xZ
S )	Tabz3Displays children each on a separate accordion tab.TabViewTr   TabModelc                 V    t        |      dkD  r	d|vrd|d<   t        |   dd|i| y )Nr   r    r$   rC   )r#   super__init__)r&   r$   kwargs	__class__s      r   rQ   zTab.__init__^   s7    x=1!1!?'(F#$5(5f5r   c                     t        | j                        }|dk(  rd | _        y | j                  d k(  rd| _        y || j                  k  r|dz
  | _        y y )Nr   r   )r#   r$   r    )r&   num_childrens     r   r0   zTab._reset_selected_indexc   sZ    4==)1"&D   D("#D D///"."2D 0r   )rC   )r>   r?   r@   rA   r   rB   rI   rJ   rQ   r0   __classcell__)rS   s   @r   rL   rL   X   s@    =#''T'2J*%))t)4K6
3r   rL   c                   p    e Zd ZdZ ed      j                  d      Z ed      j                  d      Zy)Stackz!Displays only the selected child.	StackViewTr   
StackModelNrH   rC   r   r   rX   rX   t   s5    +%))t)4J,'+++6Kr   rX   )NN)rA   
widget_boxr   widgetr   widget_corer   	traitletsr   r   r	   r
   r   r   trait_typesr   	itertoolsr   r   r   r   r   rE   rL   rX   rC   r   r   <module>ra      s      # H H # + +<9"#z 9"v 
;# ; 
; 
3
 3 
36 
7 7 
7r   