
    Xh]/                     $   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(y&)'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.
a)  
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.
behavior : str
    slider handle and connector dragging behavior. Default is 'drag-tap'.
c                 8     d fd	}t         |_        | _         S )z)Add int docstring template to class init.c                 2    |||d<   t        |   di | y Nvalue super__init__)selfr   kwargsclss      Q/var/www/html/myenv/lib/python3.12/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'   )   s    ,
 "HCLJr"   c                 8     d fd	}t         |_        | _         S )z1Add bounded int docstring template to class init.c                 \    |||d<   |||d<   |||d<   |||d<   t        |   di | y Nr   minmaxstepr   r   )r   r   r+   r,   r-   r   r    s         r!   r   z"_bounded_int_doc.<locals>.__init__6   sO    #F7O?F5M?F5M!F6Nc4!+F+r"   NNNN)_bounded_int_doc_tr%   r   r&   s   ` r!   _bounded_int_docr0   4   s    	, *HCLJr"   c                   X     e Zd ZdZ edd      j                  d      Zd fd	Z xZS )	_Intz1Base class for widgets that represent an integer.r	   z	Int valuehelpTsyncc                 2    |||d<   t        |   di | y r   r   )r   r   r   	__class__s      r!   r   z_Int.__init__J   s"    #F7O"6"r"   r#   )	__name__
__module____qualname__r%   r   tagr   r   __classcell__r8   s   @r!   r2   r2   F   s*    ;%))t)4E# #r"   r2   c                        e Zd ZdZ edd      j                  d      Z edd      j                  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 valuec                 \    |||d<   |||d<   |||d<   |||d<   t        |   di | y r*   r   )r   r   r+   r,   r-   r   r8   s         r!   r   z_BoundedInt.__init__V   sM    #F7O?F5M?F5M!F6N"6"r"   r   c                     |d   }| j                   |kD  s| j                  |k  r*t        t        || j                         | j                        }|S )zCap and floor valuer   )r+   r,   )r   proposalr   s      r!   _validate_valuez_BoundedInt._validate_valuea   sE     !88etxx%/E488,dhh7Er"   r+   c                 p    |d   }|| j                   kD  rt        d      || j                  kD  r|| _        |S )Enforce min <= value <= maxr   setting min > max)r,   r   r   )r   rF   r+   s      r!   _validate_minz_BoundedInt._validate_mini   =     w>011DJ
r"   r,   c                 p    |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_maxs   rL   r"   r.   )r9   r:   r;   r%   r   r<   r,   r+   r   r   rG   rK   rO   r=   r>   s   @r!   r@   r@   P   s    
s
%
)
)t
)
4C
q{
#
'
'T
'
2C	# g  e_  e_ r"   r@   c                      e Zd ZdZ ed      j                  d      Z ed      j                  d      Z edd      j                  d      Z	 edd	      j                  d      Z
 ed
d      j                  d      Zy)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'+++6J.)--4-8KE @AEE4EPHU  *X  Y  ]  ]  cg  ]  h=>BBBMDr"   rQ   c                      e Zd ZdZ ed      j                  d      Z ed      j                  d      Z edd      j                  d      Z	 edd	      j                  d      Z
 ed
d      j                  d      Zy)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    '+++6J/044$4?KE @AEE4EPHU  *X  Y  ]  ]  cg  ]  h=>BBBMDr"   r]   c                   v    e Zd ZdZ ed      j                  d      Z eddd      j                  d      Zy)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$5RSWW]aWbLr"   r`   c                      e Zd ZdZ ed      j                  d      Z ed      j                  d      Z edd      j                  d      Z	 e
d	d
gd	d      j                  d      Z edd      j                  d      Z edd      j                  d      Z edd      j                  d      Z edd      j                  d      Z  ee      j
                  dddieZ e
g ddd      j                  d      Zy)	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   drag-tapz	drag-snaptapdragsnaprt   Slider dragging behavior.Nr   )r9   r:   r;   r%   r   r<   rX   rY   r   r-   r   orientationr   readoutr   readout_formatr[   rZ   r   r`   r   stylebehaviorr   r"   r!   rg   rg      s-   )--4-8J*+//T/:K=>BBBMD!,
)C")BDDGCTCN 4STXX^bXcG!*,,/CTCN T(klppvzp{E @AEE4EPH)L%))LtL7KLE&V 'BDDGCTCN r"   rg   c                   v    e Zd ZdZ ed      j                  d      Z eddd      j                  d      Zy)ProgressStylera   ProgressStyleModelTr5   NzColor of the progress bar.rc   )	r9   r:   r;   r%   r   r<   rY   r   	bar_colorr   r"   r!   r   r      s<    ./333>Kdt2NOSSY]S^Ir"   r   c                      e Zd ZdZ ed      j                  d      Z ed      j                  d      Z eddgdd	      j                  d      Z	 eg d
dd	      j                  d      Z
  ee      j
                  dddieZy)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 progress bar.r6   Nr   )r9   r:   r;   r%   r   r<   rX   rY   r   ry   	bar_styler   r   r   r|   r   r"   r!   r   r      s    (,,$,7J,-11t1<K!,
)C")BDDGCTCN   ;2ACCF3D3>  ,L'++NN9MNEr"   r   c                       e Zd Z e e        e       dd      j                  d      Zed        Zej                  d        Zed        Z
e
j                  d	        Z
 ed
      d        Zy)	_IntRange)r	   r   zTuple of (lower, upper) bounds)ro   r4   Tr5   c                      | j                   d   S Nr	   r   r   s    r!   lowerz_IntRange.lower       zz!}r"   c                 0    || j                   d   f| _         y Nr   r   )r   r   s     r!   r   z_IntRange.lower   s    TZZ]+
r"   c                      | j                   d   S r   r   r   s    r!   upperz_IntRange.upper   r   r"   c                 0    | j                   d   |f| _         y r   r   )r   r   s     r!   r   z_IntRange.upper   s    jjmU+
r"   r   c                 :    |d   \  }}||k  rt        d      ||fS )Nr   zsetting lower > upper)r   )r   rF   r   r   s       r!   rG   z_IntRange._validate_value   s-    (u5=455e|r"   N)r9   r:   r;   r   r   r<   r   propertyr   setterr   r   rG   r   r"   r!   r   r      s    $&$&799<$ 
   \\, ,   \\, , g r"   r   c                      e Zd ZdZ ed      j                  d      Z ed      j                  d      Z ed      j                  d      Z	 ed      j                  d      Z
 ed	d
      j                  d      Z edd      j                  d      Z edd      j                  d      Z edd      j                  d      Zy)PlayzSPlay/repeat buttons to step through values automatically, and optionally loop.
    PlayViewTr5   	PlayModelz)Whether the control is currently playing.r3   z5Whether the control will repeat in a continuous loop.rA   z*The time between two animation steps (ms).r   zIncrement stepFrT   z,Show the repeat toggle button in the widget.N)r9   r:   r;   r%   r   r<   rX   rY   r   playingrepeatr   intervalr-   rZ   show_repeatr   r"   r!   r   r      s    $((d(3J+&***5KCDHHdHSGNOSSY]S^FCJKOOUYOZH()--4-8DE @AEE4EPHt"PQUU[_U`Kr"   r   c                        e Zd Z edd      j	                  d      Z edd      j	                  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   |j                  dd      |j                  dd      }}|j                  dd       d|z  d|z  z   d|z  d|z  z   f|d<   n%t        |d   t              s	 t        |d         |d<   t        |   |i | y #  t        dj	                  t        |d                     xY w)	Nr+   r	   r,   rA   r   g      ?g      ?z_A 'range' must be able to be cast to a tuple. The input of type {} could not be cast to a tuple)get
isinstancetuple	TypeErrorformattyper   r   )r   argsr   r+   r,   r8   s        r!   r   z_BoundedIntRange.__init__   s    ::eQ'E3)?S::gt$,#czD3J6#czD3J68F7OF7OU3"'w"8w 	$)&)77=vd6'?>S7T s   &B (B/r+   r,   c                    |d   }|d   }|j                   dk(  r|| j                  kD  rt        d      |j                   dk(  r|| j                  k  rt        d      |j                   dk(  r7t        || j                  d         t        || j                  d         f| _        |j                   dk(  r7t        || 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::3>011::c4::a=13sDJJqM3JKDJ::c4::a=13sDJJqM3JKDJ
r"   r   c                     t         |   |      \  }}t        || j                        t        || j                        }}t        || j                        t        || j                        }}||fS r#   )r   rG   r+   r,   )r   rF   r   r   r8   s       r!   rG   z _BoundedIntRange._validate_value  s^    w.x8u5$((+S-Au5$((+S-Aue|r"   )r9   r:   r;   r   r<   r,   r+   r   r   r   rG   r=   r>   s   @r!   r   r      sp    
s
%
)
)t
)
4C
q{
#
'
'T
'
2C* eU  g r"   r   c                       e Zd ZdZ ed      j                  d      Z ed      j                  d      Z edd      j                  d      Z	 e
d	d
gd	d      j                  d      Z edd      j                  d      Z edd      j                  d      Z edd      j                  d      Z  eed      j
                  dddieZ edd      j                  d      Z e
g ddd      j                  d      Zy)IntRangeSlidera  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`
    step : int
        step of the trackbar
    description : str
        name of the slider
    orientation : {'horizontal', 'vertical'}
        default is 'horizontal'
    readout : {True, False}
        default is True, display the current value of the slider next to it
    behavior : str
        slider handle and connector dragging behavior. Default is 'drag-tap'.
    readout_format : str
        default is '.2f', specifier for the format function used to represent
        slider value for human consumption, modeled after Python 3's format
        specification mini-language (PEP 3101).
    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   rs   rt   rx   Nr   )r9   r:   r;   r%   r   r<   rX   rY   r   r-   r   ry   r   rz   r   r{   r[   r   r`   r   r|   rZ   r}   r   r"   r!   r   r     s4   2 -.222=J/044$4?K>?CCCND!,
)C")BDDGCTCN 4STXX^bXcG!*,,/CTCN T(klppvzp{NL+IJNNqTXq\pqEE @AEE4EPH&V 'BDDGCTCN r"   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   r   r   r   r   r   r   r   r"   r!   <module>r      s  
 D $ 2 #  : :  
 	$#k: #+$ +Z 
	Nd N 
 
N 
N[ N  
N 
c"J c 
c 
S S  
S$ 
_$j _ 
_ 
O+ O  
O 6 
a; a 
a&y &R 
&S% &S 
&Sr"   