
    ge'*                        d Z ddlmZmZ ddlmZ ddlmZmZ ddl	m
Z
 ddlmZ ddlmZmZmZ dd	lmZmZmZmZmZmZmZmZ d
ZdZd Zd Z G d deee
          Z G d de          Zee G d de                                  Zee G d de                                  Z e G d dee
                      Z!ee G d de                                  Z"e G d dee
                      Z#ee G d de                                  Z$ G d de          Z%e G d  d!e                      Z& G d" d#e%          Z'e G d$ d%e'                      Z(d&S )'z8Int class.

Represents an unbounded int using a widget.
   )DescriptionWidgetDescriptionStyle)ValueWidget)registerwidget_serialization)
CoreWidget    )Instance)ColorInstanceDictNumberFormat)UnicodeCIntBoolCaselessStrEnumTuple
TraitErrordefaultvalidatez=
Parameters
----------
value: integer
    The initial value.
z
Parameters
----------
value: integer
    The initial value.
min: integer
    The lower limit for the value.
max: integer
    The upper limit for the value.
step: integer
    The step between allowed values.
c                 :     d fd	}t           |_        | _         S )z)Add int docstring template to class init.Nc                 L    |||d<    t          |           j        di | d S Nvalue super__init__)selfr   kwargsclss      =lib/python3.11/site-packages/ipywidgets/widgets/widget_int.pyr   z_int_doc.<locals>.__init__)   s;    #F7O!c4!++F+++++    N)
_int_doc_t__doc__r   r    r   s   ` r!   _int_docr'   '   s7    , , , , , ,
 "HCLJr"   c                 :     d fd	}t           |_        | _         S )z1Add bounded int docstring template to class init.Nc                 v    |||d<   |||d<   |||d<   |||d<    t          |           j        di | d S Nr   minmaxstepr   r   )r   r   r+   r,   r-   r   r    s         r!   r   z"_bounded_int_doc.<locals>.__init__4   sf    #F7O?F5M?F5M!F6N!c4!++F+++++r"   NNNN)_bounded_int_doc_tr%   r   r&   s   ` r!   _bounded_int_docr0   2   s7    	, 	, 	, 	, 	, 	, *HCLJr"   c                   f     e Zd ZdZ edd                              d          Zd	 fd	Z xZS )
_Intz1Base class for widgets that represent an integer.r	   z	Int valuehelpTsyncNc                 V    |||d<    t          t          |           j        di | d S r   )r   r2   r   )r   r   r   	__class__s      r!   r   z_Int.__init__H   s;    #F7O"dD",,V,,,,,r"   r#   )	__name__
__module____qualname__r%   r   tagr   r   __classcell__r8   s   @r!   r2   r2   D   sh        ;;D%%%))t)44E- - - - - - - - - -r"   r2   c                        e Zd ZdZ edd                              d          Z edd                              d          Zd fd
	Z e	d          d             Z
 e	d          d             Z e	d          d             Z xZS )_BoundedIntzSBase class for widgets that represent an integer bounded from above and below.
    d   	Max valuer3   Tr5   r	   	Min valueNc                     |||d<   |||d<   |||d<   |||d<    t          t          |           j        di | d S r*   )r   r@   r   )r   r   r+   r,   r-   r   r8   s         r!   r   z_BoundedInt.__init__T   sf    #F7O?F5M?F5M!F6N)k4  )33F33333r"   r   c                     |d         }| j         |k    s| j        |k     r(t          t          || j                   | j                  }|S )zCap and floor valuer   )r+   r,   )r   proposalr   s      r!   _validate_valuez_BoundedInt._validate_value_   sI     !8etx%//E48,,dh77Er"   r+   c                 n    |d         }|| j         k    rt          d          || j        k    r|| _        |S )Enforce min <= value <= maxr   setting min > max)r,   r   r   )r   rF   r+   s      r!   _validate_minz_BoundedInt._validate_ming   A     w>>0111DJ
r"   r,   c                 n    |d         }|| j         k     rt          d          || j        k     r|| _        |S )rI   r   setting max < min)r+   r   r   )r   rF   r,   s      r!   _validate_maxz_BoundedInt._validate_maxq   rL   r"   r.   )r9   r:   r;   r%   r   r<   r,   r+   r   r   rG   rK   rO   r=   r>   s   @r!   r@   r@   N   s         
$s
%
%
%
)
)t
)
4
4C
$q{
#
#
#
'
'T
'
2
2C	4 	4 	4 	4 	4 	4 Xg   Xe__  _ Xe__  _    r"   r@   c                   T   e Zd ZdZ ed                              d          Z ed                              d          Z edd                              d          Z	 edd	                              d          Z
 ed
d                              d          ZdS )IntTextz*Textbox widget that represents an integer.IntTextViewTr5   IntTextModelFEnable or disable user changesr3   lUpdate the value as the user types. If False, update on submission, e.g., pressing Enter or navigating away.r   #Minimum step to increment the valueNr9   r:   r;   r%   r   r<   
_view_name_model_namer   disabledcontinuous_updater   r-   r   r"   r!   rQ   rQ   {   s         54''+++66J'.))--4-88KtE @AAAEE4EPPHU  *X  Y  Y  Y  ]  ]  cg  ]  h  h4=>>>BBBMMDDDr"   rQ   c                   T   e Zd ZdZ ed                              d          Z ed                              d          Z edd                              d          Z	 edd	                              d          Z
 ed
d                              d          ZdS )BoundedIntTextzLTextbox widget that represents an integer bounded from above and below.
    rR   Tr5   BoundedIntTextModelFrT   r3   rU   r   rV   NrW   r   r"   r!   r]   r]      s         ''+++66J'/0044$4??KtE @AAAEE4EPPHU  *X  Y  Y  Y  ]  ]  cg  ]  h  h4=>>>BBBMMDDDr"   r]   c                       e Zd ZdZ ed                              d          Z eddd                              d          ZdS )SliderStyleButton style widget.SliderStyleModelTr5   NzColor of the slider handle.
allow_noner4   )	r9   r:   r;   r%   r   r<   rY   r   handle_colorr   r"   r!   r`   r`      s^        ',--11t1<<K5$5RSSSWW]aWbbLLLr"   r`   c                   P   e Zd ZdZ ed                              d          Z ed                              d          Z edd                              d          Z	 e
d	d
gd	d                              d          Z edd                              d          Z edd                              d          Z edd                              d          Z edd                              d          Z  ee          j        dddieZdS )	IntSliderzKSlider widget that represents an integer bounded from above and below.
    IntSliderViewTr5   IntSliderModelr   rV   r3   
horizontalverticalVertical or horizontal.valuesdefault_valuer4   3Display the current value of the slider next to it.dFormat for the readoutzAUpdate the value of the widget as the user is holding the slider.FrT   r6   Nr   )r9   r:   r;   r%   r   r<   rX   rY   r   r-   r   orientationr   readoutr   readout_formatr[   rZ   r   r`   r   styler   r"   r!   rg   rg      s~        ))--4-88J'*++//T/::K4=>>>BBBMMD!/,
)C")BD D DDGCTCNN d4STTTXX^bXccG!\*, , ,,/CTCNN T(klllppvzp{{tE @AAAEE4EPPH)LL%%)LLtL7KLLEEEr"   rg   c                       e Zd ZdZ ed                              d          Z eddd                              d          ZdS )ProgressStylera   ProgressStyleModelTr5   NzColor of the progress bar.rc   )	r9   r:   r;   r%   r   r<   rY   r   	bar_colorr   r"   r!   rx   rx      s^        './/333>>Kdt2NOOOSSY]S^^IIIr"   rx   c                   N   e Zd ZdZ ed                              d          Z ed                              d          Z eddgdd	                              d          Z	 eg d
dd	                              d          Z
  ee          j        dddieZdS )IntProgresszJProgress bar that represents an integer bounded from above and below.
    ProgressViewTr5   IntProgressModelrj   rk   rl   rm   )successinfowarningdanger r   z-Use a predefined styling for the progess bar.r6   Nr   )r9   r:   r;   r%   r   r<   rX   rY   r   rs   	bar_styler   rx   r   rv   r   r"   r!   r|   r|      s         ((,,$,77J',--11t1<<K!/,
)C")BD D DDGCTCNN   ;;;2@B B BBE#4#..  ,LL''+NNN9MNNEEEr"   r|   c                      e Zd Z e e             e            dd                              d          Zed             Zej	        d             Zed             Z
e
j	        d	             Z
 ed
          d             ZdS )	_IntRange)r	   r   zTuple of (lower, upper) bounds)ro   r4   Tr5   c                     | j         d         S Nr	   r   r   s    r!   lowerz_IntRange.lower       z!}r"   c                 .    || j         d         f| _         d S Nr   r   )r   r   s     r!   r   z_IntRange.lower   s    TZ]+


r"   c                     | j         d         S r   r   r   s    r!   upperz_IntRange.upper   r   r"   c                 .    | j         d         |f| _         d S r   r   )r   r   s     r!   r   z_IntRange.upper   s    jmU+


r"   r   c                 J    |d         \  }}||k     rt          d          ||fS )Nr   zsetting lower > upper)r   )r   rF   r   r   s       r!   rG   z_IntRange._validate_value   s2    (u5==4555e|r"   N)r9   r:   r;   r   r   r<   r   propertyr   setterr   r   rG   r   r"   r!   r   r      s        E$$&&$$&&79 9 99<$ 
   X \, , \,   X \, , \, Xg    r"   r   c                      e Zd ZdZ edd                              d          Z edd                              d          Z ed	d
                              d          Z	 e
d                              d          Z e
d                              d          Z ed                              d          Z ed                              d          Z edd                              d          ZdS )PlayzSPlay/repeat buttons to step through values automatically, and optionally loop.
    rA   z'The maximum value for the play control.r3   Tr5   r   zIncrement stepFrT   PlayView	PlayModelz)Whether the control is currently playing.z4Whether the control will repeat in a continous loop.z,Show the repeat toggle button in the widget.N)r9   r:   r;   r%   r   r<   intervalr-   r   rZ   r   rX   rY   _playing_repeatshow_repeatr   r"   r!   r   r      s;        tCGHHHLLRVLWWH4()))--4-88DtE @AAAEE4EPPH$$((d(33J'+&&***55KtDEEEIItITTHdNOOOSSY]S^^G$t"PQQQUU[_U``KKKr"   r   c                        e Zd Z edd                              d          Z edd                              d          Z fdZ ed	d
          d             Z	 ed           fd            Z
 xZS )_BoundedIntRangerA   rB   r3   Tr5   r	   rC   c                     |                     dd          |                     dd          }}|                     dd           sd|z  d|z  z   d|z  d|z  z   f|d<    t          t          |           j        |i | d S )Nr+   r	   r,   rA   r   g      ?g      ?)getr   r   r   )r   argsr   r+   r,   r8   s        r!   r   z_BoundedIntRange.__init__   s    ::eQ''E3)?)?Szz'4(( 	8#czD3J6#czD3J68F7O.%%.??????r"   r+   r,   c                    |d         }|d         }|j         dk    r|| j        k    rt          d          |j         dk    r|| j        k     rt          d          |j         dk    r;t          || j        d                   t          || j        d                   f| _        |j         dk    r;t          || j        d                   t          || j        d                   f| _        |S )	Ntraitr   r+   rJ   r,   rN   r	   r   )namer,   r   r+   r   )r   rF   r   news       r!   _validate_boundsz!_BoundedIntRange._validate_bounds   s    !w:3>>0111:3>>0111:c4:a=113sDJqM3J3JKDJ:c4:a=113sDJqM3J3JKDJ
r"   r   c                 
   t          t          |                               |          \  }}t          || j                  t          || j                  }}t	          || j                  t	          || j                  }}||fS r#   )r   r   rG   r+   r,   )r   rF   r   r   r8   s       r!   rG   z _BoundedIntRange._validate_value  sq    -t44DDXNNu5$(++S-A-Au5$(++S-A-Aue|r"   )r9   r:   r;   r   r<   r,   r+   r   r   r   rG   r=   r>   s   @r!   r   r      s        
$s
%
%
%
)
)t
)
4
4C
$q{
#
#
#
'
'T
'
2
2C@ @ @ @ @ XeU   Xg        r"   r   c                   T   e Zd ZdZ ed                              d          Z ed                              d          Z edd                              d          Z	 e
d	d
gd	d                              d          Z edd                              d          Z edd                              d          Z edd                              d          Z  eed          j        dddieZ edd                              d          ZdS )IntRangeSlidera5  Slider/trackbar that represents a pair of ints bounded by minimum and maximum value.

    Parameters
    ----------
    value : int tuple
        The pair (`lower`, `upper`) of integers
    min : int
        The lowest allowed value for `lower`
    max : int
        The highest allowed value for `upper`
    IntRangeSliderViewTr5   IntRangeSliderModelr   z$Minimum step that the value can taker3   rj   rk   rl   rm   rp   rq   rr   zAUpdate the value of the widget as the user is sliding the slider.zSlider style customizations.r6   FrT   Nr   )r9   r:   r;   r%   r   r<   rX   rY   r   r-   r   rs   r   rt   r   ru   r[   r   r`   r   rv   rZ   r   r"   r!   r   r     s       
 
 -..222==J'/0044$4??K4>???CCCNND!/,
)C")BD D DDGCTCNN d4STTTXX^bXccG!\*, , ,,/CTCNN T(klllppvzp{{NLL+IJJJNqqTXq\pqqEtE @AAAEE4EPPHHHr"   r   N))r%   widget_descriptionr   r   valuewidgetr   widgetr   r   widget_corer   	traitletsr
   trait_typesr   r   r   r   r   r   r   r   r   r   r   r$   r/   r'   r0   r2   r@   rQ   r]   r`   rg   rx   r|   r   r   r   r   r   r"   r!   <module>r      s   
 D C C C C C C C $ $ $ $ $ $ 2 2 2 2 2 2 2 2 # # # # # #       : : : : : : : : : :                   
 	 	 	  $- - - - -k: - - -+ + + + +$ + + +Z 
	N N N N Nd N N 
 
N 
N N N N N[ N N  
N 
c c c c c"J c c 
c 
M M M M M M M  
M" 
_ _ _ _ _$j _ _ 
_ 
O O O O O+ O O  
O       6 
a a a a a; a a 
a    y   B 
Q Q Q Q Q% Q Q 
Q Q Qr"   