Skip to content

表单提交前弹出窗口,点确认后提交,否则关闭弹出窗口不提交表单。此功能如何实现? #168

Answered by wang0618
yichangle asked this question in Q&A
Discussion options

You must be logged in to vote

可以使用锁机制来将popup变成同步的:

from pywebio import start_server
from pywebio.output import *

import threading


def confirm(title, content=None, timeout=None):
    """Show a confirm model.

    :param str title: Model title.
    :param list/put_xxx() content: Model content.
    :param None/float timeout:
    :return: Return `True` when the "CONFIRM" button is clicked, return `False` when the "CANCEL" button is clicked,
        return `None` when a timeout is given and the operation times out.
    """
    if not isinstance(content, list):
        content = [content]

    event = threading.Event()
    result = None

    def onclick(val):
        nonlocal result
        result = val
        event.set(…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@yichangle
Comment options

Answer selected by yichangle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants