L iddlmZddlZddlmZmZddlmZmZm Z m Z m Z ddl m ZddlmZer ddlmZddlmZGd d Zy) ) annotationsN) TYPE_CHECKINGcast)Height LayoutConfigWidthvalidate_heightvalidate_width)Code)gather_metrics)DeltaGenerator) SupportsStrcfeZdZed d ddddd d dZed dZy) CodeMixincodeFcontentstretch) line_numbers wrap_linesheightwidthc Pt}tjddtjddt||_|xsd|_||_||_|d}n t|dt|dt||}|jjd || S) a1Display a code block with optional syntax highlighting. Parameters ---------- body : str The string to display as code or monospace text. language : str or None The language that the code is written in, for syntax highlighting. This defaults to ``"python"``. If this is ``None``, the code will be plain, monospace text. For a list of available ``language`` values, see `react-syntax-highlighter `_ on GitHub. line_numbers : bool An optional boolean indicating whether to show line numbers to the left of the code block. This defaults to ``False``. wrap_lines : bool An optional boolean indicating whether to wrap lines. This defaults to ``False``. height : "content", "stretch", or int The height of the code block element. This can be one of the following: - ``"content"`` (default): The height of the element matches the height of its content. - ``"stretch"``: The height of the element matches the height of its content or the height of the parent container, whichever is larger. If the element is not in a parent container, the height of the element matches the height of its content. - An integer specifying the height in pixels: The element has a fixed height. If the content is larger than the specified height, scrolling is enabled. .. note:: Use scrolling containers sparingly. If you use scrolling containers, avoid heights that exceed 500 pixels. Otherwise, the scroll surface of the container might cover the majority of the screen on mobile devices, which makes it hard to scroll the rest of the app. width : "stretch", "content", or int The width of the code block element. This can be one of the following: - ``"stretch"`` (default): The width of the element matches the width of the parent container. - ``"content"``: The width of the element matches the width of its content, but doesn't exceed the width of the parent container. - An integer specifying the width in pixels: The element has a fixed width. If the specified width is greater than the width of the parent container, the width of the element matches the width of the parent container. Examples -------- >>> import streamlit as st >>> >>> code = '''def hello(): ... print("Hello, Streamlit!")''' >>> st.code(code, language="python") .. output :: https://doc-code.streamlit.app/ height: 220px >>> import streamlit as st >>> code = '''Is it a crown or boat? ... ii ... iiiiii ... WWw .iiiiiiii. ...: ... WWWWWWw .iiiiiiiiiiii. ........ ... WWWWWWWWWWw iiiiiiiiiiiiiiii ........... ... WWWWWWWWWWWWWWwiiiiiiiiiiiiiiiii............ ... WWWWWWWWWWWWWWWWWWwiiiiiiiiiiiiii......... ... WWWWWWWWWWWWWWWWWWWWWWwiiiiiiiiii....... ... WWWWWWWWWWWWWWWWWWWWWWWWWWwiiiiiii.... ... WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWwiiii. ... -MMMWWWWWWWWWWWWWWWWWWWWWWMMM- ... ''' >>> st.code(code, language=None) .. output :: https://doc-code-ascii.streamlit.app/ height: 380px z\n\Zz\A\n plaintextrT) allow_content)rrr) layout_config) CodeProtoresubstr code_textlanguageshow_line_numbersrr r rdg_enqueue) selfbodyr"rrrr code_protors ]/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/streamlit/elements/code.pyrzCodeMixin.code$sH[ !vvgr266'2s4y3QR &5+ '3 $ *  >F F$ 7uD1$F%@ ww -PPctd|S)zGet our DeltaGenerator.r )r)r&s r)r$z CodeMixin.dgs$d++r*N)python)r'rr"z str | Nonerboolrr-rz Height | Nonerrreturnr )r.r )__name__ __module__ __qualname__r rpropertyr$r*r)rr#sF (pQ # ) pQpQpQ  pQ  pQpQpQ pQpQd,,r*r) __future__rrtypingrr#streamlit.elements.lib.layout_utilsrrrr r streamlit.proto.Code_pb2r rstreamlit.runtime.metrics_utilr streamlit.delta_generatorr streamlit.type_utilrrr3r*r)r;s7# &798/w,w,r*