Str#
Open this notebook in Jupyterlite | Download this notebook from GitHub (right-click to download).
import panel as pn
pn.extension()
The Str pane allows rendering arbitrary text in a panel.
Unlike Markdown and HTML panes, a Str pane is interpreted as a raw string without applying any markup and is displayed in a fixed-width font by default.
The pane will render any text, and if given an object will display the object’s Python str representation.
Parameters:#
For details on other options for customizing the component see the layout and styling how-to guides.
enable_streaming(boolean, default=False): Whether to enable streaming of text updates. When enabled, each update toobjectis diffed against the previous value and only the changed portion is sent to the frontend.object(str or object): The string to display. If a non-string type is supplied, thestrof that object is displayed.
str_pane = pn.pane.Str(
'This is a raw string which will not be formatted in any way except for the applied style.',
styles={'font-size': '12pt'}
)
str_pane
Like other panes the Str pane can be updated by setting its object parameter. As mentioned above, non-string types are automatically cast to a string:
str_pane.object = 1.3234232
Since the text is rendered in a <pre> block, whitespace and line breaks are preserved, which makes the Str pane well suited for displaying logs or the output of other Python objects:
import numpy as np
pn.pane.Str(np.random.default_rng(42).random((4, 3)).round(3))
Open this notebook in Jupyterlite | Download this notebook from GitHub (right-click to download).