L i.bUddlmZddlZddlmZddlmZddlmZm Z m Z m Z m Z m Z ddlmZddlmZmZddlmZmZmZdd lmZmZdd lmZmZmZmZmZdd l m!Z!m"Z"m#Z#m$Z$m%Z%dd l&m'Z(dd l)m*Z*ddl+m,Z,m-Z-ddl.m/Z/m0Z0m1Z1m2Z2m3Z3ddl4m5Z5erddl6m7Z7e8e9zZ:de;d<e de8dZ<e de9dZ=eGddZ>GddZ?y)) annotationsN) dataclass)dedent) TYPE_CHECKINGLiteral TypeAliasTypeVarcastoverload)current_form_id)JSNumberJSNumberBoundsException) LayoutConfigWidthWithoutContentvalidate_width)check_widget_policiesmaybe_raise_label_warnings)KeyLabelVisibilitycompute_and_register_element_id get_label_visibility_proto_valueto_key)!StreamlitInvalidNumberFormatErrorStreamlitJSNumberBoundsErrorStreamlitMixedNumericTypesErrorStreamlitValueAboveMaxErrorStreamlitValueBelowMinError) NumberInput)gather_metrics)ScriptRunContextget_script_run_ctx) WidgetArgsWidgetCallback WidgetKwargsget_session_stateregister_widget)validate_icon_or_emoji)DeltaGeneratorrNumber IntOrNone FloatOrNonec2eZdZUded<ded<ddZd dZy) NumberInputSerde Number | Nonevalueint data_typec|SN)selfvs m/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/streamlit/elements/widgets/number_input.py serializezNumberInputSerde.serializeIscz||n |j}|(|jtjk(r t |}|Sr3)r/r1NumberInputProtoINTr0)r5ui_valuevals r7 deserializezNumberInputSerde.deserializeLs7)1)=X4:: ?t~~1A1E1EEc(C r9N)r6r.returnr.)r=r.r@r.)__name__ __module__ __qualname____annotations__r8r?r4r9r7r-r-Ds Nr9r-cfeZdZe ddddddd ddZe ddddddddddddddd dd Ze dddddddddddddd dd Ze ddddddddddddd dd Ze ddddddd ddZed ddddddd ddZ dddddddd ddZed dZy)!NumberInputMixinNminFvisiblestretch) placeholderdisabledlabel_visibilityiconwidthc yr3r4r5label min_value max_valuer/stepformatkeyhelp on_changeargskwargsrJrKrLrMrNs r7 number_inputzNumberInputMixin.number_inputZ(r9) r/rTrUrVrWrXrYrZrJrKrLrMrNcyr3r4rPs r7r[zNumberInputMixin.number_inputtr\r9) rTrUrVrWrXrYrZrJrKrLrMrNc yr3r4rPs r7r[zNumberInputMixin.number_inputs(r9) rUrVrWrXrYrZrJrKrLrMrNc yr3r4rPs r7r[zNumberInputMixin.number_inputr\r9c yr3r4rPs r7r[zNumberInputMixin.number_inputs("r9r[c Zt}|j||||||||| | | | | ||||S)uFDisplay a numeric input widget. .. note:: Integer values exceeding +/- ``(1<<53) - 1`` cannot be accurately stored or returned by the widget due to serialization constraints between the Python server and JavaScript client. You must handle such numbers as floats, leading to a loss in precision. Parameters ---------- label : str A short label explaining to the user what this input is for. The label can optionally contain GitHub-flavored Markdown of the following types: Bold, Italics, Strikethroughs, Inline Code, Links, and Images. Images display like icons, with a max height equal to the font height. Unsupported Markdown elements are unwrapped so only their children (text contents) render. Display unsupported elements as literal characters by backslash-escaping them. E.g., ``"1\. Not an ordered list"``. See the ``body`` parameter of |st.markdown|_ for additional, supported Markdown directives. For accessibility reasons, you should never set an empty label, but you can hide it with ``label_visibility`` if needed. In the future, we may disallow empty labels by raising an exception. .. |st.markdown| replace:: ``st.markdown`` .. _st.markdown: https://docs.streamlit.io/develop/api-reference/text/st.markdown min_value : int, float, or None The minimum permitted value. If this is ``None`` (default), there will be no minimum for float values and a minimum of ``- (1<<53) + 1`` for integer values. max_value : int, float, or None The maximum permitted value. If this is ``None`` (default), there will be no maximum for float values and a maximum of ``(1<<53) - 1`` for integer values. value : int, float, "min" or None The value of this widget when it first renders. If this is ``"min"`` (default), the initial value is ``min_value`` unless ``min_value`` is ``None``. If ``min_value`` is ``None``, the widget initializes with a value of ``0.0`` or ``0``. If ``value`` is ``None``, the widget will initialize with no value and return ``None`` until the user provides input. step : int, float, or None The stepping interval. Defaults to 1 if the value is an int, 0.01 otherwise. If the value is not specified, the format parameter will be used. format : str or None A printf-style format string controlling how the interface should display numbers. The output must be purely numeric. This does not impact the return value of the widget. For more information about the formatting specification, see `sprintf.js `_. For example, ``format="%0.1f"`` adjusts the displayed decimal precision to only show one digit after the decimal. key : str or int An optional string or integer to use as the unique key for the widget. If this is omitted, a key will be generated for the widget based on its content. No two widgets may have the same key. help : str or None A tooltip that gets displayed next to the widget label. Streamlit only displays the tooltip when ``label_visibility="visible"``. If this is ``None`` (default), no tooltip is displayed. The tooltip can optionally contain GitHub-flavored Markdown, including the Markdown directives described in the ``body`` parameter of ``st.markdown``. on_change : callable An optional callback invoked when this number_input's value changes. args : list or tuple An optional list or tuple of args to pass to the callback. kwargs : dict An optional dict of kwargs to pass to the callback. placeholder : str or None An optional string displayed when the number input is empty. If None, no placeholder is displayed. disabled : bool An optional boolean that disables the number input if set to ``True``. The default is ``False``. label_visibility : "visible", "hidden", or "collapsed" The visibility of the label. The default is ``"visible"``. If this is ``"hidden"``, Streamlit displays an empty spacer instead of the label, which can help keep the widget aligned with other widgets. If this is ``"collapsed"``, Streamlit displays no label or spacer. icon : str, None An optional emoji or icon to display within the input field to the left of the value. If ``icon`` is ``None`` (default), no icon is displayed. If ``icon`` is a string, the following options are valid: - A single-character emoji. For example, you can set ``icon="🚨"`` or ``icon="🔥"``. Emoji short codes are not supported. - An icon from the Material Symbols library (rounded style) in the format ``":material/icon_name:"`` where "icon_name" is the name of the icon in snake case. For example, ``icon=":material/thumb_up:"`` will display the Thumb Up icon. Find additional icons in the `Material Symbols \ `_ font library. width : "stretch" or int The width of the number input widget. This can be one of the following: - ``"stretch"`` (default): The width of the widget matches the width of the parent container. - An integer specifying the width in pixels: The widget has a fixed width. If the specified width is greater than the width of the parent container, the width of the widget matches the width of the parent container. Returns ------- int or float or None The current value of the numeric input widget or ``None`` if the widget is empty. The return type will match the data type of the value parameter. Example ------- >>> import streamlit as st >>> >>> number = st.number_input("Insert a number") >>> st.write("The current number is ", number) .. output:: https://doc-number-input.streamlit.app/ height: 260px To initialize an empty number input, use ``None`` as the value: >>> import streamlit as st >>> >>> number = st.number_input( ... "Insert a number", value=None, placeholder="Type a number..." ... ) >>> st.write("The current number is ", number) .. output:: https://doc-number-input-empty.streamlit.app/ height: 260px )rQrRrSr/rTrUrVrWrXrYrZrJrKrLrMrNctx)r! _number_input)r5rQrRrSr/rTrUrVrWrXrYrZrJrKrLrMrNrbs r7r[zNumberInputMixin.number_inputsXp!"!!#-#"  r9)rJrKrLrMrNrbc ~ t|}t|j|| |dk7r|ndt||t d|hd|j|||||||| dn t | ||}||||g}t d|D}t d|D}|s|st||||tj}| ||vr||d}|dk(r||}n|r|rd }n|rd }nd }t|tj}t|t}| |r|sd }nd }||rd nd n|}|dvr|rd dl}|jd|dn#|ddk(r|rd dl}|jd|d||rdnd} t|dz|xr|}||||kDr t'||||||kr t)|| |r| t+j,t/|dnt*j0}| t+j,t/|dnt*j2}|t+j,t/|d|t+j,t/|dn|t+j4|dnt*j6}|t+j4|dnt*j8}|t+j4|d|t+j4|d|rt>j@nt>jB}t?}||_"||_#||_$|||_%| t | |_&tO|j|_(| |_)tU||jV_,|t[||_.|||_/d |_0|||_1d |_2|||_3||_4|tk||_6to||}tq|jD| | | |jr|jt|d} | jvr| jX|j`r:| jX|j^kr!t'| jX|j^|jdr:| jX|jbkDr!t)| jX|jb| jX|_,d |_<t{|t}| }!|jjd||!!| jXS#t t"f$r t%|wxYw#t:$r}t=t |d}~wwxYw)"NrG) default_valuer[>rTrSrR) user_keykey_as_main_identitydgrQrRrSr/rTrUrWrJrMrNc3pK|].}t|tjtdtf0ywr3) isinstancenumbersIntegraltypestr.0as r7 z1NumberInputMixin._number_input..s0  q7++T$Z= > s46c3\K|]$}t|ttdtf&ywr3)rjfloatrmrnros r7rrz1NumberInputMixin._number_input..s' 89Jq5$t*c2 3 s*,)r/rRrSrTgrT%dz%0.2f)ruz%uz%iz%t  #5*:;4 "Dww + 3[9I! (' 5$? &   =N  N1yID *+:: ?sm3 c8J8RE E>$!.ug&6&67  . =N # =CNPV  . .; " JJ,o-BD 2 # %) " JJ;;H/L  <!1tD C -!# $ -  U%69u;L-EYO O  U%69u;L-EYO O! 7(00YO!) 9 9I(00YO!) 9 9I#00THE$00UYG(229mL!) ; ;I(229mL!) 2 2I#224B$225)D-5$((:J:P:P -/ *'0$#(  ).  &  "-0-=  *%4TWW%="&.#4T 5 ++1  &,Tl  #  %.  ")-  &  %.  ")-  &  &*  #$1!  &rs#!MM=N L9O98%K  Kd + mUD1       C ,C ,r9