L i6ddlmZddlmZddlmZddlmZmZddl m Z ddl m Z m Z mZddlmZmZddlmZmZmZmZmZdd lmZdd lmZdd lmZmZdd l m!Z!m"Z"m#Z#m$Z$erdd l%m&Z&eGddZ'GddZ(y)) annotations) dataclass)dedent) TYPE_CHECKINGcast)current_form_id) LayoutConfigWidthvalidate_width)check_widget_policiesmaybe_raise_label_warnings)KeyLabelVisibilitycompute_and_register_element_id get_label_visibility_proto_valueto_key)Checkbox)gather_metrics)ScriptRunContextget_script_run_ctx) WidgetArgsWidgetCallback WidgetKwargsregister_widget)DeltaGeneratorc(eZdZUded<ddZddZy) CheckboxSerdeboolvaluect|SN)r)selfvs i/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/streamlit/elements/widgets/checkbox.py serializezCheckboxSerde.serialize8s Awc<t||S|jSr!)rr)r"ui_values r$ deserializezCheckboxSerde.deserialize;s 4HEE$**EEr&N)r#rreturnr)r(z bool | Noner*r)__name__ __module__ __qualname____annotations__r%r)r&r$rr4s KFr&rc\eZdZed d dddd ddZed d dddd dd Z d ddejjddd  dd Z e dd Z y) CheckboxMixincheckboxFNvisiblecontent)disabledlabel_visibilitywidthct} |j||||||||| tjj| |  S)a1Display a checkbox widget. Parameters ---------- label : str A short label explaining to the user what this checkbox 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 : bool Preselect the checkbox when it first renders. This will be cast to bool internally. 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 checkbox'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 checkbox 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 : "content", "stretch", or int The width of the checkbox 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 ------- bool Whether or not the checkbox is checked. Example ------- >>> import streamlit as st >>> >>> agree = st.checkbox("I agree") >>> >>> if agree: ... st.write("Great!") .. output:: https://doc-checkbox.streamlit.app/ height: 220px labelrkeyhelp on_changeargskwargsr5r6typectxr7)r _checkbox CheckboxProto StyleTypeDEFAULT r"r:rr;r<r=r>r?r5r6r7rAs r$r2zCheckboxMixin.checkbox@sS\!"~~-((00  r&togglect} |j||||||||| tjj| |  S)a.Display a toggle widget. Parameters ---------- label : str A short label explaining to the user what this toggle 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 : bool Preselect the toggle when it first renders. This will be cast to bool internally. 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 toggle'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 toggle 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 : "content", "stretch", or int The width of the toggle 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 ------- bool Whether or not the toggle is checked. Example ------- >>> import streamlit as st >>> >>> on = st.toggle("Activate feature") >>> >>> if on: ... st.write("Feature activated!") .. output:: https://doc-toggle.streamlit.app/ height: 220px r9)rrBrCrDTOGGLErFs r$rGzCheckboxMixin.togglesS\!"~~-((//  r&)r5r6r@rAr7c 6t|}t|j|||durdn|t|| t | t j jk(rdnd|d|j|t||| } t }| |_ ||_ t||_ | |_ t|j|_||_t!| |j"_|t'||_t+| dt-| }t/|}t1|j||||j2|j4| d }|j6r|j$|_d|_|jj;d|| |j$S) NF) default_valuerGr2T)user_keykey_as_main_identitydgr:rr<r7) allow_content)r7 bool_value)on_change_handlerr>r? deserializer serializerrA value_type) layout_config)rr rNr rrCrDrIridr:defaultr@rform_idr5rr6rrr<r r rrr)r% value_changed set_value_enqueue)r"r:rr;r<r=r>r?r5r6r@rAr7 element_idcheckbox_protorUserdecheckbox_states r$rBzCheckboxMixin._checkbox<s Sk GG  "'5.$e  #5*:;4 7 7 > >>HJ!%wwu+  '&$!%e"!0!9"*0P 1 ''-  "(,N uD1$51 e$(   '**#    ' '#1#7#7N '+N $ ^=Q###r&ctd|S)zGet our DeltaGenerator.r)r)r"s r$rNzCheckboxMixin.dgs$d++r&)FNNNNN)r:strrrr; Key | Noner< str | Noner=WidgetCallback | Noner>WidgetArgs | Noner?WidgetKwargs | Noner5rr6rr7r r*r)r:rarrr;rbr<rcr=rdr>rer?rfr5rr6rr@z!CheckboxProto.StyleType.ValueTyperAzScriptRunContext | Noner7r r*r)r*r) r+r,r-rr2rGrCrDrErBpropertyrNr/r&r$r1r1?sOJ+/"&&*{ ,5 { { {  {  { ) {  { ${ { *{ {  {  { zH+/"&&*{ ,5 { { {  {  { ) {  { ${ { *{ {  { { @+/"&&*H$,52?2I2I2Q2Q'+ H$H$H$ H$  H$ ) H$ H$$H$H$*H$0H$%H$H$ H$T,,r&r1N)) __future__r dataclassesrtextwraprtypingrr!streamlit.elements.lib.form_utilsr#streamlit.elements.lib.layout_utilsr r r streamlit.elements.lib.policiesr r streamlit.elements.lib.utilsrrrrrstreamlit.proto.Checkbox_pb2rrCstreamlit.runtime.metrics_utilrstreamlit.runtime.scriptrunnerrrstreamlit.runtime.staterrrrstreamlit.delta_generatorrrr1r/r&r$rusu#!&= C9O8 FF FJ,J,r&