Toggle¶
Toggle
¶
Toggles act as a container that holds a list of nested Block objects, whose visibility can be toggled on or off by the report viewer
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*arg_blocks
|
BlockOrPrimitive
|
Group to add to report |
()
|
blocks
|
list[BlockOrPrimitive]
|
Allows providing the report blocks as a single list |
None
|
name
|
BlockId
|
A unique id for the blocks to aid querying (optional) |
None
|
label
|
str
|
A label used when displaying the block (optional) |
None
|
report_minimum_blocks = 1
class-attribute
instance-attribute
¶
Simple Toggle¶
import seaborn as sns
import altair as alt
code = """
titanic = sns.load_dataset("titanic")
app = dip.App(
"# Titanic overview",
dip.HTML(
'<html><img alt="No description has been provided for this image" src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/fd/RMS_Titanic_3.jpg/1599px-RMS_Titanic_3.jpg" style="height:400px;display:flex;margin:auto"/></html>'
),
dip.Select(
blocks=[
dip.Table(titanic.describe(), label="Data Description"),
dip.DataTable(titanic, label="Whole Dataset"),
dip.Code(code, label="Source code"),
]
),
)
app.save(path="select.html")
"""
titanic = sns.load_dataset("titanic")
dip.Blocks(
"# Titanic overview",
dip.HTML(
'<html><img alt="No description has been provided for this image" src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/fd/RMS_Titanic_3.jpg/1599px-RMS_Titanic_3.jpg" style="height:400px;display:flex;margin:auto"/></html>'
),
dip.Toggle(
blocks=[
dip.Table(titanic.describe(), label="Data Description"),
dip.DataTable(titanic, label="Whole Dataset"),
dip.Code(code, label="Source code"),
]
),
)