Example #1
0
    def __init__(
        self, parent=None, python_namespace=None, callbacks=[], debug=True,
        root_paths={}
    ):
        super(ProxyQWebView, self).__init__(parent)
        self.setPage(ProxyQWebPage())

        # Connect JS with python.
        self.expose_python_namespace(python_namespace, callbacks)

        # Install custom access manager to handle '/jigna' requests.
        access_manager = ProxyAccessManager(root_paths=root_paths)
        self.page().setNetworkAccessManager(access_manager)

        # Disable some actions
        for action in self.DISABLED_ACTIONS:
            self.pageAction(action).setVisible(False)

        # Setup debug flag
        self.page().settings().setAttribute(
            QtWebKit.QWebSettings.DeveloperExtrasEnabled, debug
        )

        # Set sizing policy
        self.setSizePolicy(
            QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding
        )