How to use the pscript.window.setTimeout function in pscript

To help you get started, we’ve selected a few pscript examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github flexxui / flexx / flexx / ui / widgets / _dropdown.py View on Github external
def _expand(self):
        # Expand
        self.node.classList.add('expanded')
        # Collapse when the node changes position (e.g. scroll or layout change)
        rect = self.node.getBoundingClientRect()
        self._rect_to_check = rect
        window.setTimeout(self._check_expanded_pos, 100)
        # Collapse when the mouse is used outside the combobox (or its children)
        self._addEventListener(window.document, 'mousedown', self._collapse_maybe, 1)
        # Return rect so subclasses can use it
        return rect
github flexxui / flexx / flexx / ui / widgets / _dropdown.py View on Github external
def _check_expanded_pos(self):
        if self.node.classList.contains('expanded'):
            rect = self.node.getBoundingClientRect()
            if not (rect.top == self._rect_to_check.top and
                    rect.left == self._rect_to_check.left):
                self._collapse()
            else:
                window.setTimeout(self._check_expanded_pos, 100)
github flexxui / flexx / flexx / ui / _widget.py View on Github external
if self.parent:
            return

        # Let session keep us up to date about size changes
        # (or make it stop if we dont have a container anymore)
        self._session.keep_checking_size_of(self, bool(id))

        if id:
            if id == 'body':
                el = window.document.body
                self.outernode.classList.add('flx-main-widget')
                window.document.title = self.title or 'Flexx app'
            else:
                el = window.document.getElementById(id)
                if el is None:  # Try again later
                    window.setTimeout(self.__container_changed, 100)
                    return
            el.appendChild(self.outernode)