Output collapsible content :param str title: Title of content :type content: list/str/put_xxx() :param content: The content can be a string, the ``put_xxx()`` calls , or a list of them. :param bool open: Whether to expand the content. Default is ``False``. :param int scope, posi
(title: str, content: Union[str, Output, List[Union[str, Output]]] = [], open: bool = False,
scope: str = None, position: int = OutputPosition.BOTTOM)
| 1105 | |
| 1106 | @safely_destruct_output_when_exp('content') |
| 1107 | def put_collapse(title: str, content: Union[str, Output, List[Union[str, Output]]] = [], open: bool = False, |
| 1108 | scope: str = None, position: int = OutputPosition.BOTTOM) -> Output: |
| 1109 | """Output collapsible content |
| 1110 | |
| 1111 | :param str title: Title of content |
| 1112 | :type content: list/str/put_xxx() |
| 1113 | :param content: The content can be a string, the ``put_xxx()`` calls , or a list of them. |
| 1114 | :param bool open: Whether to expand the content. Default is ``False``. |
| 1115 | :param int scope, position: Those arguments have the same meaning as for `put_text()` |
| 1116 | |
| 1117 | Example: |
| 1118 | |
| 1119 | .. exportable-codeblock:: |
| 1120 | :name: put_collapse |
| 1121 | :summary: `put_collapse()` usage |
| 1122 | |
| 1123 | put_collapse('Collapse title', [ |
| 1124 | 'text', |
| 1125 | put_markdown('~~Strikethrough~~'), |
| 1126 | put_table([ |
| 1127 | ['Commodity', 'Price'], |
| 1128 | ['Apple', '5.5'], |
| 1129 | ]) |
| 1130 | ], open=True) |
| 1131 | |
| 1132 | ## ---- |
| 1133 | put_collapse('Large text', 'Awesome PyWebIO! '*30) |
| 1134 | """ |
| 1135 | if not isinstance(content, (list, tuple, OutputList)): |
| 1136 | content = [content] |
| 1137 | |
| 1138 | for item in content: |
| 1139 | assert isinstance(item, (str, Output)), "put_collapse() content must be list of str/put_xxx()" |
| 1140 | |
| 1141 | tpl = """<details {{#open}}open{{/open}}> |
| 1142 | <summary>{{title}}</summary> |
| 1143 | {{#contents}} |
| 1144 | {{& pywebio_output_parse}} |
| 1145 | {{/contents}} |
| 1146 | </details>""" |
| 1147 | return put_widget(tpl, dict(title=title, contents=content, open=open), scope=scope, |
| 1148 | position=position).enable_context_manager() |
| 1149 | |
| 1150 | |
| 1151 | @safely_destruct_output_when_exp('content') |
no test coverage detected
searching dependent graphs…