L igtddlmZddlmZddlmZddlmZmZm Z m Z ddl m Z ddl mZmZmZmZmZddlmZmZddlmZmZmZmZmZdd lmZdd lmZ dd l!m"Z#dd l$m%Z%dd l&m'Z'm(Z(ddl)m*Z*m+Z+m,Z,m-Z-m.Z.ddl/m0Z0ddl1m2Z2er ddl3m4Z4ddl1m2Z2eGddZ5eGddZ6GddZ7y)) annotations) dataclass)dedent) TYPE_CHECKINGLiteralcastoverload)current_form_id)Height LayoutConfigWidthWithoutContentvalidate_heightvalidate_width)check_widget_policiesmaybe_raise_label_warnings)KeyLabelVisibilitycompute_and_register_element_id get_label_visibility_proto_valueto_key)StreamlitAPIException)TextArea) TextInput)gather_metrics)ScriptRunContextget_script_run_ctx) WidgetArgsWidgetCallback WidgetKwargsget_session_stateregister_widget)validate_icon_or_emoji) SupportsStr)DeltaGeneratorc(eZdZUded<ddZddZy)TextInputSerde str | Nonevaluec"||S|jSNr(selfui_values m/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/streamlit/elements/widgets/text_widgets.py deserializezTextInputSerde.deserialize@#/x?TZZ?c|Sr*r-vs r/ serializezTextInputSerde.serializeCr2Nr.r'returnr'r6r'r:r'__name__ __module__ __qualname____annotations__r0r7r4r2r/r&r&< @r2r&c(eZdZUded<ddZddZy) TextAreaSerder'r(c"||S|jSr*r+r,s r/r0zTextAreaSerde.deserializeKr1r2c|Sr*r4r5s r/r7zTextAreaSerde.serializeNr8r2Nr9r;r<r4r2r/rCrCGrAr2rCceZdZe ddddddd ddZe ddddddd ddZed ddddddd dd Z dddddddd  dd Ze dddddd  dd Ze dddddd  ddZed dddddd  ddZ ddddddd ddZe d dZ y)!TextWidgetsMixinNFvisiblestretch) placeholderdisabledlabel_visibilityiconwidthc yr*r4r-labelr( max_charskeytypehelp autocomplete on_changeargskwargsrJrKrLrMrNs r/ text_inputzTextWidgetsMixin.text_inputS( r2c yr*r4rPs r/rZzTextWidgetsMixin.text_inputir[r2rZc Xt}|j||||||||| | | | | |||S)u#Display a single-line text input widget. 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 value : object or None The text value of this widget when it first renders. This will be cast to str internally. If ``None``, will initialize empty and return ``None`` until the user provides input. Defaults to empty string. max_chars : int or None Max number of characters allowed in text input. 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. type : "default" or "password" The type of the text input. This can be either "default" (for a regular text input), or "password" (for a text input that masks the user's typed value). Defaults to "default". 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``. autocomplete : str An optional value that will be passed to the element's autocomplete property. If unspecified, this value will be set to "new-password" for "password" inputs, and the empty string for "default" inputs. For more details, see https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete on_change : callable An optional callback invoked when this text 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 text input is empty. If None, no text is displayed. disabled : bool An optional boolean that disables the text 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. 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 text 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 ------- str or None The current value of the text input widget or ``None`` if no value has been provided by the user. Example ------- >>> import streamlit as st >>> >>> title = st.text_input("Movie title", "Life of Brian") >>> st.write("The current movie title is", title) .. output:: https://doc-text-input.streamlit.app/ height: 260px )rQr(rRrSrTrUrVrWrXrYrJrKrLrMrNctx)r _text_input)r-rQr(rRrSrTrUrVrWrXrYrJrKrLrMrNr^s r/rZzTextWidgetsMixin.text_inputsUh!"%#-!   r2)rJrKrLrMrNr^c ft|}t|j|||dk(rdn|t|| | t |nd}t d|dh|j||||||t | || }t j}| ||vr||d}t}||_ ||_ |||_ t|j|_ | |_t| |j _|t%||_|||_| t | |_|t-||_|dk(rtj0|_n*|dk(rtj4|_nt7d|d | |dk(rd nd}||_t;|}t=|j|| | |j>|j@|d }|jBr$|j"|j"|_d |_"tG|tI|}|jjKd|||j"S)N default_valuerZrR) user_keykey_as_main_identitydgrQr(rRrTrUrVrJrMrNdefaultpassword'zK' is not a valid text_input type. Valid types are 'default' and 'password'.z new-password string_valueon_change_handlerrXrY deserializer serializerr^ value_typeT)rN layout_config)&rrrfrstrrr filtered_stateTextInputProtoidrQrgr form_idrKrrLr(rrUrRrJr"rMDEFAULTrTPASSWORDrrVr&r!r0r7 value_changed set_valuerr _enqueue)r-rQr(rRrSrTrUrVrWrXrYrJrKrLrMrNr^ element_id session_statetext_input_protoserde widget_staterqs r/r_zTextWidgetsMixin._text_input'sg(Sk GG  "'2+$5  #5*:;$/E T4 #.ww%K( $*+:: ?sm3 c8J8RE)+(!&  ',  $#2477#; $,!2R 3 ))/  $*4L  !  )2  &  "+.{+;  (  $:4$@  ! 9 $2$:$:  ! Z $2$;$;  !'D6de   -1Z-?>RL(4%u%&   '**%    % %!!-)5);); &)-  &u$51  '7}U!!!r2)rJrKrLrNc yr*r4r-rQr(heightrRrSrUrWrXrYrJrKrLrNs r/ text_areazTextWidgetsMixin.text_area$ r2c yr*r4rs r/rzTextWidgetsMixin.text_arearr2rc Tt}|j||||||||| | | | | |S)aDisplay a multi-line text input widget. 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 value : object or None The text value of this widget when it first renders. This will be cast to str internally. If ``None``, will initialize empty and return ``None`` until the user provides input. Defaults to empty string. height : "content", "stretch", int, or None The height of the text area widget. This can be one of the following: - ``None`` (default): The height of the widget fits three lines. - ``"content"``: The height of the widget matches the height of its content. - ``"stretch"``: The height of the widget matches the height of its content or the height of the parent container, whichever is larger. If the widget is not in a parent container, the height of the widget matches the height of its content. - An integer specifying the height in pixels: The widget has a fixed height. If the content is larger than the specified height, scrolling is enabled. The widget's height can't be smaller than the height of two lines. When ``label_visibility="collapsed"``, the minimum height is 68 pixels. Otherwise, the minimum height is 98 pixels. max_chars : int or None Maximum number of characters allowed in text area. 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 text_area'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 text area is empty. If None, no text is displayed. disabled : bool An optional boolean that disables the text area 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. width : "stretch" or int The width of the text area 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 ------- str or None The current value of the text area widget or ``None`` if no value has been provided by the user. Example ------- >>> import streamlit as st >>> >>> txt = st.text_area( ... "Text to analyze", ... "It was the best of times, it was the worst of times, it was the age of " ... "wisdom, it was the age of foolishness, it was the epoch of belief, it " ... "was the epoch of incredulity, it was the season of Light, it was the " ... "season of Darkness, it was the spring of hope, it was the winter of " ... "despair, (...)", ... ) >>> >>> st.write(f"You wrote {len(txt)} characters.") .. output:: https://doc-text-area.streamlit.app/ height: 300px )rQr(rrRrSrUrWrXrYrJrKrLrNr^)r _text_area)r-rQr(rrRrSrUrWrXrYrJrKrLrNr^s r/rzTextWidgetsMixin.text_areasMb!"#-  r2)rJrKrLrNr^c t|}t|j|||dk(rdn|t|| | t |nd}t d|dh|j|||||t | |  }t j}| ||vr||d}t}||_ ||_ |||_ t|j|_ | |_t| |j _|t%||_|||_| t | |_t-|}t/|j||| |j0|j2|d}|j4r$|j"|j"|_d|_t9| |t;|d n | d k7rd nd }t=| | }|jj?d|||j"S)NrarbrrR) rdrerfrQr(rrRrUrJrNrjrkT) allow_content collapsedz^)rNrrp) rrrfrrrrr rs TextAreaProtorurQrgr rvrKrrLr(rrUrRrJrCr!r0r7ryrzrrr r{)r-rQr(rrRrSrUrWrXrYrJrKrLrNr^r|r}text_area_protorrrqs r/rzTextWidgetsMixin._text_areags$Sk GG  "'2+$5  #5*:;#/E T4 #.wwK( *+:: ?sm3 c8J8RE'/' %  &+O #"1$''":#+ 1Q 2 ((.  #)$r?r rZrr_rrpropertyrfr4r2r/rGrGRs&  $/8#'+/"&&* #',5%.#       -   ! )   $    * ! "## $ %  *%) $/8#'+/"&&* #',5%.#  "     -   ! )   $    * ! "## $ %  *L!+- $/8#'+/"&&*e #',5%.#e e (e  e  e - e e !e )e  e $e  e e *e !e "##e $ %e "e T%' $#'+/"&&*s"#',5%.'+%s"s""s" s"  s"  s"s"!s")s" s"$s" s"s"*s" !s""##s"$%%s"& 's"j $ $+/"&&* #',5%.          )   $    * # !  &%) $ $+/"&&* #',5%.  "        )   $    * # !  &K +- $ $+/"&&*` #',5%.` ` (`  `  `  ` ` )`  ` $`  ` ` *` #` !` !` J%' $ $+/"&&*d"#',5%.'+!d"d""d" d"  d"  d"d")d" d"$d" d"d"*d"#d" %!d"" #d"L,,r2rGN)8 __future__r dataclassesrtextwraprtypingrrrr !streamlit.elements.lib.form_utilsr #streamlit.elements.lib.layout_utilsr r r rrstreamlit.elements.lib.policiesrrstreamlit.elements.lib.utilsrrrrrstreamlit.errorsrstreamlit.proto.TextArea_pb2rrstreamlit.proto.TextInput_pb2rrtstreamlit.runtime.metrics_utilrstreamlit.runtime.scriptrunnerrrstreamlit.runtime.staterrrr r!streamlit.string_utilr"streamlit.type_utilr#streamlit.delta_generatorr$r&rCrGr4r2r/rs#!99=3BE9O9+8/    ~ ,~ ,r2