MCPcopy Index your code
hub / github.com/pywebio/PyWebIO / put_scrollable

Function put_scrollable

pywebio/output.py:1152–1209  ·  view source on GitHub ↗

Output a fixed height content area. scroll bar is displayed when the content exceeds the limit :type content: list/str/put_xxx() :param content: The content can be a string, the ``put_xxx()`` calls , or a list of them. :param int/tuple height: The height of the area (in pixels).

(content: Union[str, Output, List[Union[str, Output]]] = [],
                   height: Union[int, Tuple[int, int]] = 400, keep_bottom: bool = False, border: bool = True,
                   scope: str = None, position: int = OutputPosition.BOTTOM, **kwargs)

Source from the content-addressed store, hash-verified

1150
1151@safely_destruct_output_when_exp('content')
1152def put_scrollable(content: Union[str, Output, List[Union[str, Output]]] = [],
1153 height: Union[int, Tuple[int, int]] = 400, keep_bottom: bool = False, border: bool = True,
1154 scope: str = None, position: int = OutputPosition.BOTTOM, **kwargs) -> Output:
1155 """Output a fixed height content area. scroll bar is displayed when the content exceeds the limit
1156
1157 :type content: list/str/put_xxx()
1158 :param content: The content can be a string, the ``put_xxx()`` calls , or a list of them.
1159 :param int/tuple height: The height of the area (in pixels).
1160 ``height`` parameter also accepts ``(min_height, max_height)`` to indicate the range of height, for example,
1161 ``(100, 200)`` means that the area has a minimum height of 100 pixels and a maximum of 200 pixels.
1162 Set ``None`` if you don't want to limit the height
1163 :param bool keep_bottom: Whether to keep the content area scrolled to the bottom when updated.
1164 :param bool border: Whether to show border
1165 :param int scope, position: Those arguments have the same meaning as for `put_text()`
1166
1167 Example:
1168
1169 .. exportable-codeblock::
1170 :name: put_scrollable
1171 :summary: `put_scrollable()` usage
1172
1173 import time
1174
1175 put_scrollable(put_scope('scrollable'), height=200, keep_bottom=True)
1176 put_text("You can click the area to prevent auto scroll.", scope='scrollable')
1177
1178 while 1:
1179 put_text(time.time(), scope='scrollable')
1180 time.sleep(0.5)
1181
1182 .. versionchanged:: 1.1
1183 add ``height`` parameter,remove ``max_height`` parameter;
1184 add ``keep_bottom`` parameter
1185
1186 .. versionchanged:: 1.5
1187 remove ``horizon_scroll`` parameter
1188 """
1189 if not isinstance(content, (list, tuple, OutputList)):
1190 content = [content]
1191
1192 content = [i if isinstance(i, Output) else put_text(i) for i in content]
1193
1194 if 'max_height' in kwargs:
1195 import warnings
1196
1197 # use stacklevel=2 to make the warning refer to the put_scrollable() call
1198 warnings.warn("`max_height` parameter is deprecated in `put_scrollable()`, use `height` instead.",
1199 DeprecationWarning, stacklevel=2)
1200 height = kwargs['max_height'] # Backward compatible
1201
1202 if isinstance(height, int): # height is a int
1203 min_height, max_height = height, height
1204 else: # height is a tuple of (min_height, max_height)
1205 min_height, max_height = height
1206
1207 spec = _get_output_spec('scrollable', contents=content, min_height=min_height, max_height=max_height,
1208 keep_bottom=keep_bottom, border=border, scope=scope, position=position)
1209 return Output(spec).enable_context_manager(container_selector='> div')

Callers 3

basic_outputFunction · 0.85
output_widgetsFunction · 0.85
mainFunction · 0.85

Calls 4

put_textFunction · 0.85
_get_output_specFunction · 0.85
OutputClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…