Skip to content

Blocking function awaiting response from widget #678

Answered by psychemedia
psychemedia asked this question in Python
Discussion options

You must be logged in to vote

Ah, thanks for that.

The jupyter_ui_poll approach appears to work in a jupyter served browser environment:

# %pip install jupyter_ui_poll

from anywidget import AnyWidget
from traitlets import Unicode, Float
from jupyter_ui_poll import ui_events

import time

class BlockingMessageWidget(AnyWidget):
    message = Unicode('').tag(sync=True)
    reply = Unicode('').tag(sync=True)
    progress = Float(0.0).tag(sync=True)
    
    def __init__(self):
        super().__init__()

    def send_message(self, msg):
        self.reply = ''
        self.progress = 0.0
        self.message = '' # So we state change the message
        self.message = msg

    def blocking_reply(self, timeout=None):
   …

Replies: 1 comment 1 reply

Comment options

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

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