How to use the pscript.stubs.window.addEventListener 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 / app / _clientcore.py View on Github external
window.console.ori_warn(msg)
            for session in self.sessions.values():
                session.send_command("WARN", str(msg))
        def error(msg):
            evt = dict(message=str(msg), error=msg, preventDefault=lambda: None)
            on_error(evt)
        def on_error(evt):
            self._handle_error(evt)
        on_error = on_error.bind(self)
        # Set new versions
        window.console.log = log
        window.console.info = info
        window.console.warn = warn
        window.console.error = error
        # Create error handler, so that JS errors get into Python
        window.addEventListener('error', on_error, False)
github flexxui / flexx / flexx / app / _clientcore.py View on Github external
self.is_exported = False

        # Copy attributes from temporary object (e.g. is_notebook, require, ...)
        for key in window.flexx.keys():
            self[key] = window.flexx[key]

        # We need a global main widget (shared between sessions)
        self.need_main_widget = True  # Used/set in ui/_widget.py

        # Keep track of sessions
        self._session_count = 0
        self.sessions = {}

        # Note: flexx.init() is not auto-called when Flexx is embedded
        window.addEventListener('load', self.init, False)
        window.addEventListener('unload', self.exit, False)  # not beforeunload
github flexxui / flexx / flexx / app / _clientcore.py View on Github external
self.is_notebook = False
        self.is_exported = False

        # Copy attributes from temporary object (e.g. is_notebook, require, ...)
        for key in window.flexx.keys():
            self[key] = window.flexx[key]

        # We need a global main widget (shared between sessions)
        self.need_main_widget = True  # Used/set in ui/_widget.py

        # Keep track of sessions
        self._session_count = 0
        self.sessions = {}

        # Note: flexx.init() is not auto-called when Flexx is embedded
        window.addEventListener('load', self.init, False)
        window.addEventListener('unload', self.exit, False)  # not beforeunload
github flexxui / flexx / flexx / app / _clientcore.py View on Github external
# Init internal variables
        self._init_time = time()
        self._pending_commands = []  # to pend raw commands during init
        self._asset_count = 0
        self._ws = None
        self.last_msg = None
        # self.classes = {}
        self.instances = {}
        self.instances_to_check_size = {}

        if not window.flexx.is_exported:
            self.init_socket()

        # Initiate service to track resize
        # Note that only toplevel widgets are tracked, and only once per sec
        window.addEventListener('resize', self._check_size_of_objects, False)
        window.setInterval(self._check_size_of_objects, 1000)