L i>ddlmZddlmZddlmZddlmZmZm Z m Z m Z m Z m Z ddlmZmZddlmZddlmZmZddlmZmZmZdd lmZmZdd lmZmZm Z m!Z!m"Z"m#Z#dd l$m%Z%dd l&m'Z(dd l)m*Z*ddl+m,Z,m-Z-ddl.m/Z/m0Z0m1Z1m2Z2ddl3m4Z4erddl5m6Z6m7Z7ddl8m9Z9ddlm:Z:ddl;meGdde e=Z?GddZ@y)) annotations) dataclass)dedent) TYPE_CHECKINGAnyGeneric TypeGuardTypeVarcastoverload)OptionSequenceconvert_anything_to_list)current_form_id) LayoutConfigvalidate_width)index_maybe_coerce_enummaybe_coerce_enum_sequence)check_widget_policiesmaybe_raise_label_warnings)KeyLabelVisibilitycompute_and_register_element_id get_label_visibility_proto_valuesave_for_app_testingto_key)StreamlitAPIException)Slider)gather_metrics)ScriptRunContextget_script_run_ctx) WidgetArgsWidgetCallback WidgetKwargsregister_widget)check_python_comparable)CallableSequence)DeltaGenerator)WidthWithoutContent)RegisterWidgetResultTc.t|ttfSN) isinstancelisttuple)values n/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/streamlit/elements/widgets/select_slider.py_is_range_valuer4Gs edE] ++cDeZdZUded<ded<ded<d dZd dZd d Zy )SelectSliderSerdez Sequence[T]options list[int]r2boolis_range_valuec$|j|Sr.)_as_index_list)selfvs r3 serializezSelectSliderSerde.serializeQs""1%%r5c|s j}tdtfd|D}jr|S|dS)N tuple[T, T]c3NK|]}jt|ywr.)r8int).0xr>s r3 z0SelectSliderSerde.deserialize..\s91$,,s1v&9s"%r)r2r r1r;)r>ui_value return_values` r3 deserializezSelectSliderSerde.deserializeTsEzzH%)  99 9% $22|G QGr5ct|r3|Dcgc]}t|j|}}|\}}||kDr||g}|St|j|gScc}wr.)r4rr8)r>r?val slider_valuestartends r3r=z SelectSliderSerde._as_index_listbsa 1 ABC#F4<<5CLC%JE3s{ #U|  t||Q'(( DsAN)r?objectreturnr9)rHzlist[int] | NonerQT | tuple[T, T]r?rrQr9)__name__ __module__ __qualname____annotations__r@rJr=r5r3r7r7Ks$  & H)r5r7c eZdZeedddddfdddd d dZeddedddddfdddd ddZed ddedddddfdddd dd Zddedddddddddf dd Zedd Z y)SelectSliderMixinNFvisiblestretch)disabledlabel_visibilitywidthc yr.rX r>labelr8r2 format_funckeyhelp on_changeargskwargsr]r^r_s r3 select_sliderzSelectSliderMixin.select_sliderms r5rXc yr.rXras r3rizSelectSliderMixin.select_sliders r5ric Rt} |j||||||||| | | | |  S)a Display a slider widget to select items from a list. This also allows you to render a range slider by passing a two-element tuple or list as the ``value``. The difference between ``st.select_slider`` and ``st.slider`` is that ``select_slider`` accepts any datatype and takes an iterable set of options, while ``st.slider`` only accepts numerical or date/time data and takes a range as input. Parameters ---------- label : str A short label explaining to the user what this slider 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 options : Iterable Labels for the select options in an ``Iterable``. This can be a ``list``, ``set``, or anything supported by ``st.dataframe``. If ``options`` is dataframe-like, the first column will be used. Each label will be cast to ``str`` internally by default. value : a supported type or a tuple/list of supported types or None The value of the slider when it first renders. If a tuple/list of two values is passed here, then a range slider with those lower and upper bounds is rendered. For example, if set to `(1, 10)` the slider will have a selectable range between 1 and 10. Defaults to first option. format_func : function Function to modify the display of the labels from the options. argument. It receives the option as an argument and its output will be cast to str. 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 select_slider'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. disabled : bool An optional boolean that disables the select slider 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 slider 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 ------- any value or tuple of any value The current value of the slider widget. The return type will match the data type of the value parameter. This contains copies of the selected options, not the originals. Examples -------- >>> import streamlit as st >>> >>> color = st.select_slider( ... "Select a color of the rainbow", ... options=[ ... "red", ... "orange", ... "yellow", ... "green", ... "blue", ... "indigo", ... "violet", ... ], ... ) >>> st.write("My favorite color is", color) And here's an example of a range select slider: >>> import streamlit as st >>> >>> start_color, end_color = st.select_slider( ... "Select a range of color wavelength", ... options=[ ... "red", ... "orange", ... "yellow", ... "green", ... "blue", ... "indigo", ... "violet", ... ], ... value=("red", "blue"), ... ) >>> st.write("You selected wavelengths between", start_color, "and", end_color) .. output:: https://doc-select-slider.streamlit.app/ height: 450px ) rbr8r2rcrdrerfrgrhr]r^ctxr_)r!_select_slider)r>rbr8r2rcrdrerfrgrhr]r^r_rls r3rizSelectSliderMixin.select_slidersLH!"""#-#  r5ct|}t|j||t|| t |t t dk(r tddfd }|}td|ddh|j|Dcgc]}t||c}|||  }t}||_ tjj|_||_d |_||j"ddd|_t d z |_d |_tj*|_Dcgc]}t||c}|j.ddt1|j|_| |_t7| |j8_|t=||_tA| tC| }tE|tG}tI|j||| |jJ|jL| d }tO|j:tPrtStUd||}n tW||}|jXr/|jM|j:|j:ddd|_-| r t]| |||jj_d|||j:Scc}wcc}w)N) default_valuerz,The `options` argument needs to be non-emptyct|r)|Dcgc]}t|}}|\}}||kDr||g}|S t|gScc}w#t$r dgcYSwxYw)Nr)r4r ValueError)r?rLrMrNrOoptr2s r3 as_index_listz7SelectSliderMixin._select_slider..as_index_listfs~q!<=>SsC 0> >) s3;$'rbr8r2rcrdrerfrgrhr]r^rlr_rsrMoption element_id slider_protor~serde widget_staterrs ` @r3rmz SelectSliderMixin._select_sliderFs Sk GG    #5*:;&w/$ s8q='(VW W "%U+ 4 #,]!;ww <}M!!!oA #Os J;5Kctd|S)zGet our DeltaGenerator.r))r )r>s r3rvzSelectSliderMixin.dgs$d++r5)rbrr8OptionSequence[T]r2ztuple[T, T] | list[T]rcCallable[[Any], Any]rd Key | Nonere str | NonerfWidgetCallback | NonergWidgetArgs | NonerhWidgetKwargs | Noner]r:r^rr_r*rQrB)rbrr8rr2zT | Nonercrrdrrerrfrrgrrhrr]r:r^rr_r*rQr,)rbrr8rr2T | Sequence[T] | Nonercrrdrrerrfrrgrrhrr]r:r^rr_r*rQrR)rbrr8rr2rrcrrdrrerrfrrgrrhrr]r:r^rrlzScriptRunContext | Noner_r*rQrR)rQr)) rTrUrVr rrirrmpropertyrvrXr5r3rZrZls# -0+/"&&*,5%.#%  *   ) $*# "&(,/+/"&&*,5%.#  *   ) $*# "O$&((,,/+/"&&*r ,5%.r r #r & r * r  r r )r  r $r r *r #r  r %r n&((,,/+/"&&*,5'+%.s"s"#s"& s" * s"  s"s")s" s"$s"s"*s"%s"#s" s"j,,r5rZN)r2zT | Sequence[T]rQzTypeGuard[Sequence[T]])A __future__r dataclassesrtextwraprtypingrrrr r r r streamlit.dataframe_utilr r!streamlit.elements.lib.form_utilsr#streamlit.elements.lib.layout_utilsrr-streamlit.elements.lib.options_selector_utilsrrrstreamlit.elements.lib.policiesrrstreamlit.elements.lib.utilsrrrrrrstreamlit.errorsrstreamlit.proto.Slider_pb2rrstreamlit.runtime.metrics_utilrstreamlit.runtime.scriptrunnerr r!streamlit.runtime.stater"r#r$r%streamlit.type_utilr&collections.abcr'r(streamlit.delta_generatorr)r*streamlit.runtime.state.commonr+r,r4r7rZrXr5r3rs#!N=L 3<9O 828GC CL, ) ) )@R,R,r5