How to use the pscript.stubs.window.flexx.require 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
def instantiate_component(self, module, cname, id, args, kwargs, active_components):
        # Maybe we still have the instance?
        c = self.instances.get(id, None)
        if c is not None and c._disposed is False:
            return c
        # Find the class
        m = window.flexx.require(module)
        Cls = m[cname]  # noqa
        # Instantiate. If given, replicate the active components by which the
        # JsComponent was instantiated in Python.
        kwargs['flx_session'] = self
        kwargs['flx_id'] = id
        active_components = active_components or []
        for ac in active_components:
            ac.__enter__()
        try:
            c = Cls(*args, **kwargs)
        finally:
            for ac in reversed(active_components):
                ac.__exit__()
        return c