L iz?ddlmZddlmZddlmZddlmZmZm Z m Z m Z m Z ddl mZddlmZmZddlmZddlmZmZmZdd lmZmZdd lmZmZdd lmZm Z m!Z!m"Z"m#Z#m$Z$dd l%m&Z&dd l'm(Z)ddl*m+Z+ddl,m-Z-m.Z.ddl/m0Z0m1Z1m2Z2m3Z3m4Z4ddl5m6Z6erddl7m8Z8m9Z9ddl:m;Z;e dZy)) annotations) dataclass)dedent) TYPE_CHECKINGAnyGenericTypeVarcastoverload)Never)OptionSequenceconvert_anything_to_list)current_form_id) LayoutConfigWidthvalidate_width)index_maybe_coerce_enum)check_widget_policiesmaybe_raise_label_warnings)KeyLabelVisibilitycompute_and_register_element_id get_label_visibility_proto_valuesave_for_app_testingto_key)StreamlitAPIException)Radio)gather_metrics)ScriptRunContextget_script_run_ctx) WidgetArgsWidgetCallback WidgetKwargsget_session_stateregister_widget)check_python_comparable)CallableSequence)DeltaGeneratorTc2eZdZUded<ded<ddZd dZy) RadioSerdez Sequence[T]options int | Noneindexch|yt|jdk(rdSt|j|SNr)lenr.r)selfvs f/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/streamlit/elements/widgets/radio.py serializezRadioSerde.serializeGs0 9 %*qGt||Q0GGc||n |j}|6t|jdkDr|j||j|SdSr2)r0r3r.)r4ui_valueidxs r6 deserializezRadioSerde.deserializeMsV".hDJJDLL!A% S!- LL    r8N)r5objectreturnr/)r:r/r>T | None)__name__ __module__ __qualname____annotations__r7r<r8r6r-r-Bs  H  r8r-c4eZdZededddddfdddddd ddZededddddfdddddd ddZeedddddfdddddd dd Zed dedddddfdddddd dd Zdedddddfdddddd  dd ZeddZ y) RadioMixinrNFvisiblecontent)disabled horizontalcaptionslabel_visibilitywidthc yNrDr4labelr.r0 format_funckeyhelp on_changeargskwargsrIrJrKrLrMs r6radiozRadioMixin.radioZs$r8c yrOrDrPs r6rXzRadioMixin.radions$ r8c yrOrDrPs r6rXzRadioMixin.radios$r8rXc Vt}|j||||||||| | | | | ||S)aDisplay a radio button widget. Parameters ---------- label : str A short label explaining to the user what this radio group 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. Labels can include markdown as described in the ``label`` parameter and will be cast to str internally by default. index : int or None The index of the preselected option on first render. If ``None``, will initialize empty and return ``None`` until the user selects an option. Defaults to 0 (the first option). format_func : function Function to modify the display of radio options. It receives the raw option as an argument and should output the label to be shown for that option. This has no impact on the return value of the radio. 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 radio'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 radio button if set to ``True``. The default is ``False``. horizontal : bool An optional boolean, which orients the radio group horizontally. The default is false (vertical buttons). captions : iterable of str or None A list of captions to show below each radio button. If None (default), no captions are shown. 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 : "content", "stretch", or int The width of the radio button widget. This can be one of the following: - ``"content"`` (default): The width of the widget matches the width of its content, but doesn't exceed the width of the parent container. - ``"stretch"``: 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 The selected option or ``None`` if no option is selected. This is a copy of the selected option, not the original. Example ------- >>> import streamlit as st >>> >>> genre = st.radio( ... "What's your favorite movie genre", ... [":rainbow[Comedy]", "***Drama***", "Documentary :movie_camera:"], ... captions=[ ... "Laugh out loud.", ... "Get the popcorn.", ... "Never stop learning.", ... ], ... ) >>> >>> if genre == ":rainbow[Comedy]": ... st.write("You selected comedy.") ... else: ... st.write("You didn't select comedy.") .. output:: https://doc-radio.streamlit.app/ height: 300px To initialize an empty radio widget, use ``None`` as the index value: >>> import streamlit as st >>> >>> genre = st.radio( ... "What's your favorite movie genre", ... [":rainbow[Comedy]", "***Drama***", "Documentary :movie_camera:"], ... index=None, ... ) >>> >>> st.write("You selected:", genre) .. output:: https://doc-radio-empty.streamlit.app/ height: 300px )rQr.r0rRrSrTrUrVrWrIrJrKrLctxrM)r!_radio)r4rQr.r0rRrSrTrUrVrWrIrJrKrLrMr\s r6rXzRadioMixin.radiosPN!"{{#!-  r8)rIrJrLrKrMc t|}t|j|||dk(rdn|t|| t |dt |}t |}t|td|dh|j||Dcgc]}t||c}||| | | }t|ts#|!td t|j|9t|dkDr+d|cxkrt|kstd td dd }t!j"}| ||vr||d}t%}||_||_|||_|Dcgc]}t||c}|j,ddt/|j|_| |_| |_t7| |j8_| t=|| |j>dd|tA||_!tE||}tG|j&||| |jH|jJ|d }tM|||}|jNr7|j:$|jK|j:}|||_d|_(|r tS||||jjUd|||j:Scc}wcc}w)Nr) default_valueT) allow_content)rMrXr.) user_keykey_as_main_identitydgrQr.r0rTrJrKrMzRadio Value has invalid type: z3Radio index must be between 0 and length of optionscn|yt|tr|Stdt|j)Nz-Radio captions must be strings. Passed type: ) isinstancestrrtyper@)captions r6handle_captionsz*RadioMixin._radio..handle_captionss;'3''?W @V@V?WX r8 int_value)on_change_handlerrVrW deserializer serializerr\ value_type) layout_config)ri str | Noner>rg)+rrrcrrrrr'rrgrfintrrhr@r3r%filtered_state RadioProtoidrQdefaultr.rform_idrJrIrrLvaluemaprKrrTr-r&r<r7r value_changed set_valuer_enqueue)r4rQr.r0rRrSrTrUrVrWrIrJrLrKr\rMrpoptoption element_idrj session_state radio_protoserde widget_stateserialized_values r6r]zRadioMixin._radioPs&Sk GG  "'1*$%  #5*:;uD1$51 &w/$4  #,ww +]K!!!UAH"Ns J:J?ctd|S)zGet our DeltaGenerator.r*)r )r4s r6rcz RadioMixin.dgs$d++r8)rQrgr.zSequence[Never]r0rrrRCallable[[Any], Any]rS Key | NonerTrqrUWidgetCallback | NonerVWidgetArgs | NonerWWidgetKwargs | NonerIboolrJrrKSequence[str] | NonerLrrMrr>None)rQrgr.OptionSequence[T]r0rrrRrrSrrTrqrUrrVrrWrrIrrJrrKrrLrrMrr>r+)rQrgr.rr0rrRrrSrrTrqrUrrVrrWrrIrrJrrKrrLrrMrr>r?)rQrgr.rr0r/rRrrSrrTrqrUrrVrrWrrIrrJrrKrrLrrMrr>r?) rQrgr.rr0r/rRrrSrrTrqrUrrVrrWrrIrrJrrLrrKrr\zScriptRunContext | NonerMrr>r?)r>r*) r@rArBr rgrXrr]propertyrcrDr8r6rFrFYs` ,/+/"&&* )-,5 !!  *   ) $'* !" #& ,/+/"&&* )-,5 !#  *   ) $'* !" #& -0+/"&&* )-,5 !#  *   ) $'* !" #&G ,/+/"&&*w  )-,5 !w w #w  w * w  w w )w  w $w w w 'w *w !w " #w w z,/+/"&&*x" ,5)- #x"x"#x" x" * x"  x"x")x" x"$x"x"x"*x"'x" %!x""#x"$ %x"t,,r8rFN)? __future__r dataclassesrtextwraprtypingrrrr r r typing_extensionsr streamlit.dataframe_utilr r!streamlit.elements.lib.form_utilsr#streamlit.elements.lib.layout_utilsrrr-streamlit.elements.lib.options_selector_utilsrrstreamlit.elements.lib.policiesrrstreamlit.elements.lib.utilsrrrrrrstreamlit.errorsrstreamlit.proto.Radio_pb2rrtstreamlit.runtime.metrics_utilrstreamlit.runtime.scriptrunnerr r!streamlit.runtime.stater"r#r$r%r&streamlit.type_utilr'collections.abcr(r)streamlit.delta_generatorr*r+r-rFrDr8r6rs#!GG#M= T399O28 CL     ,t,t,r8