Show a popup. ⚠️: In PyWebIO, you can't show multiple popup windows at the same time. Before displaying a new pop-up window, the existing popup on the page will be automatically closed. You can use `close_popup()` to close the popup manually. :param str title: The title of the pop
(title: str, content: Union[str, Output, List[Union[str, Output]]] = None, size: str = PopupSize.NORMAL,
implicit_close: bool = True,
closable: bool = True)
| 1969 | |
| 1970 | @safely_destruct_output_when_exp('content') |
| 1971 | def popup(title: str, content: Union[str, Output, List[Union[str, Output]]] = None, size: str = PopupSize.NORMAL, |
| 1972 | implicit_close: bool = True, |
| 1973 | closable: bool = True): |
| 1974 | """ |
| 1975 | Show a popup. |
| 1976 | |
| 1977 | ⚠️: In PyWebIO, you can't show multiple popup windows at the same time. Before displaying a new pop-up window, |
| 1978 | the existing popup on the page will be automatically closed. You can use `close_popup()` to close the popup manually. |
| 1979 | |
| 1980 | :param str title: The title of the popup. |
| 1981 | :type content: list/str/put_xxx() |
| 1982 | :param content: The content of the popup. Can be a string, the put_xxx() calls, or a list of them. |
| 1983 | :param str size: The size of popup window. Available values are: ``'large'``, ``'normal'`` and ``'small'``. |
| 1984 | :param bool implicit_close: If enabled, the popup can be closed implicitly by clicking the content outside |
| 1985 | the popup window or pressing the ``Esc`` key. Default is ``False``. |
| 1986 | :param bool closable: Whether the user can close the popup window. By default, the user can close the popup |
| 1987 | by clicking the close button in the upper right of the popup window. |
| 1988 | When set to ``False``, the popup window can only be closed by :func:`popup_close()`, |
| 1989 | at this time the ``implicit_close`` parameter will be ignored. |
| 1990 | |
| 1991 | ``popup()`` can be used in 2 ways: direct call and context manager. |
| 1992 | |
| 1993 | * direct call: |
| 1994 | |
| 1995 | .. exportable-codeblock:: |
| 1996 | :name: popup |
| 1997 | :summary: `popup()` usage |
| 1998 | |
| 1999 | popup('popup title', 'popup text content', size=PopupSize.SMALL) |
| 2000 | ## ---- |
| 2001 | |
| 2002 | popup('Popup title', [ |
| 2003 | put_html('<h3>Popup Content</h3>'), |
| 2004 | 'html: <br/>', |
| 2005 | put_table([['A', 'B'], ['C', 'D']]), |
| 2006 | put_buttons(['close_popup()'], onclick=lambda _: close_popup()) |
| 2007 | ]) |
| 2008 | |
| 2009 | * context manager: |
| 2010 | |
| 2011 | .. exportable-codeblock:: |
| 2012 | :name: popup-context |
| 2013 | :summary: `popup()` as context manager |
| 2014 | |
| 2015 | with popup('Popup title') as s: |
| 2016 | put_html('<h3>Popup Content</h3>') |
| 2017 | put_text('html: <br/>') |
| 2018 | put_buttons([('clear()', s)], onclick=clear) |
| 2019 | |
| 2020 | put_text('Also work!', scope=s) |
| 2021 | |
| 2022 | |
| 2023 | The context manager will open a new output scope and return the scope name. |
| 2024 | The output in the context manager will be displayed on the popup window by default. |
| 2025 | After the context manager exits, the popup window will not be closed. |
| 2026 | You can still use the ``scope`` parameter of the output function to output to the popup. |
| 2027 | |
| 2028 | """ |
no test coverage detected
searching dependent graphs…