How to use the cefpython3.cefpython.SetGlobalClientCallback function in cefpython3

To help you get started, we’ve selected a few cefpython3 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 james-owen-ryan / talktown-testbed / browser.py View on Github external
if TEST_EMBEDDING_IN_PANEL:
                print("Embedding in a wx.Panel!")
                # You also have to set the wx.WANTS_CHARS style for
                # all parent panels/controls, if it's deeply embedded.
                self.mainPanel = wx.Panel(self, style=wx.WANTS_CHARS)

            # Global client callbacks must be set before browser is created.
            self.clientHandler = ClientHandler()
            cefpython.SetGlobalClientCallback("OnCertificateError",
                    self.clientHandler._OnCertificateError)
            cefpython.SetGlobalClientCallback("OnBeforePluginLoad",
                    self.clientHandler._OnBeforePluginLoad)
            cefpython.SetGlobalClientCallback("OnAfterCreated",
                    self.clientHandler._OnAfterCreated)

            windowInfo = cefpython.WindowInfo()
            windowInfo.SetAsChild(self.GetHandleForBrowser())
            self.browser = cefpython.CreateBrowserSync(windowInfo,
                    browserSettings=g_browserSettings,
                    navigateUrl=url)

            self.clientHandler.mainBrowser = self.browser
            self.browser.SetClientHandler(self.clientHandler)

            jsBindings = cefpython.JavascriptBindings(
                bindToFrames=False, bindToPopups=True)
            jsBindings.SetFunction("PyPrint", PyPrint)
            jsBindings.SetProperty("pyProperty", "This was set in Python")
            jsBindings.SetProperty("pyConfig", ["This was set in Python",
github carlosperate / ardublockly / start_cef.py View on Github external
# This utility function will adjust width/height using
            # OS DPI settings. For 800/600 with Win7 DPI settings
            # being set to "Larger 150%" will return 1200/900.
            size = cefpython.DpiAware.CalculateWindowSize(size[0], size[1])

        self.SetSize(size)

        if not url:
            url = "http://localhost:8000/ardublockly/index.html"

        # Also have to set wx.WANTS_CHARS style for all parent panels/controls
        self.mainPanel = wx.Panel(self, style=wx.WANTS_CHARS)

        # Global client callbacks must be set before browser is created.
        self.clientHandler = ClientHandler()
        cefpython.SetGlobalClientCallback("OnCertificateError",
                self.clientHandler._OnCertificateError)
        cefpython.SetGlobalClientCallback("OnBeforePluginLoad",
                self.clientHandler._OnBeforePluginLoad)
        cefpython.SetGlobalClientCallback("OnAfterCreated",
                self.clientHandler._OnAfterCreated)

        windowInfo = cefpython.WindowInfo()
        windowInfo.SetAsChild(self.GetHandleForBrowser())
        self.browser = cefpython.CreateBrowserSync(
            windowInfo,
            browserSettings=g_browserSettings,
            navigateUrl=url)

        self.clientHandler.mainBrowser = self.browser
        self.browser.SetClientHandler(self.clientHandler)
github cztomczak / cefpython / src / windows / deprecated_32bit / wxpython.py View on Github external
if not url:
            url = "file://"+GetApplicationPath("wxpython.html")
            # Test hash in url.
            # url += "#test-hash"

        self.CreateMenu()

        if TEST_EMBEDDING_IN_PANEL:
            print("Embedding in a wx.Panel!")
            # You also have to set the wx.WANTS_CHARS style for
            # all parent panels/controls, if it's deeply embedded.
            self.mainPanel = wx.Panel(self, style=wx.WANTS_CHARS)

        # Global client callbacks must be set before browser is created.
        self.clientHandler = ClientHandler()
        cefpython.SetGlobalClientCallback("OnCertificateError",
                self.clientHandler._OnCertificateError)
        cefpython.SetGlobalClientCallback("OnBeforePluginLoad",
                self.clientHandler._OnBeforePluginLoad)
        cefpython.SetGlobalClientCallback("OnAfterCreated",
                self.clientHandler._OnAfterCreated)

        windowInfo = cefpython.WindowInfo()
        windowInfo.SetAsChild(self.GetHandleForBrowser())
        self.browser = cefpython.CreateBrowserSync(windowInfo,
                browserSettings=g_browserSettings,
                navigateUrl=url)

        self.clientHandler.mainBrowser = self.browser
        self.browser.SetClientHandler(self.clientHandler)

        jsBindings = cefpython.JavascriptBindings(
github McGill-DMaS / Kam1n0-Community / Kam1n0WinSetupProject / bin_release / plugins / Kam1n0 / Forms / CloneSearchRenderForm.py View on Github external
url = "file://"+GetApplicationPath("www/CloneGraph.html")
            # Test hash in url.
            # url += "#test-hash"


        if TEST_EMBEDDING_IN_PANEL:
            print("Embedding in a wx.Panel!")
            # You also have to set the wx.WANTS_CHARS style for
            # all parent panels/controls, if it's deeply embedded.
            self.mainPanel = wx.Panel(self, style=wx.WANTS_CHARS)

        # Global client callbacks must be set before browser is created.
        self.clientHandler = ClientHandler()
        cefpython.SetGlobalClientCallback("OnCertificateError",
                self.clientHandler._OnCertificateError)
        cefpython.SetGlobalClientCallback("OnBeforePluginLoad",
                self.clientHandler._OnBeforePluginLoad)
        cefpython.SetGlobalClientCallback("OnAfterCreated",
                self.clientHandler._OnAfterCreated)

        windowInfo = cefpython.WindowInfo()
        windowInfo.SetAsChild(self.GetHandleForBrowser())
        self.browser = cefpython.CreateBrowserSync(windowInfo,
                browserSettings=g_browserSettings,
                navigateUrl=url)

        self.clientHandler.mainBrowser = self.browser
        self.browser.SetClientHandler(self.clientHandler)

        jsBindings = cefpython.JavascriptBindings(
            bindToFrames=False, bindToPopups=True)
        jsBindings.SetFunction("PyPrint", PyPrint)
github McGill-DMaS / Kam1n0-Community / kam1n0-clients / ida-plugin / Kam1n0 / utilities / RequestPage.py View on Github external
def set_global_handler():
    def on_after_create(browser, **_):
        cef.WindowUtils.SetTitle(browser, 'Kam1n0')
        bindings = cef.JavascriptBindings(
            bindToFrames=True, bindToPopups=False)
        bindings.SetObject("browser_controller", BrowserController(browser))
        bindings.SetFunction("send_msg", send_msg)
        browser.SetJavascriptBindings(bindings)

    cef.SetGlobalClientCallback("OnAfterCreated", on_after_create)
github cztomczak / cefpython / src / windows / deprecated_32bit / wxpython.py View on Github external
# Test hash in url.
            # url += "#test-hash"

        self.CreateMenu()

        if TEST_EMBEDDING_IN_PANEL:
            print("Embedding in a wx.Panel!")
            # You also have to set the wx.WANTS_CHARS style for
            # all parent panels/controls, if it's deeply embedded.
            self.mainPanel = wx.Panel(self, style=wx.WANTS_CHARS)

        # Global client callbacks must be set before browser is created.
        self.clientHandler = ClientHandler()
        cefpython.SetGlobalClientCallback("OnCertificateError",
                self.clientHandler._OnCertificateError)
        cefpython.SetGlobalClientCallback("OnBeforePluginLoad",
                self.clientHandler._OnBeforePluginLoad)
        cefpython.SetGlobalClientCallback("OnAfterCreated",
                self.clientHandler._OnAfterCreated)

        windowInfo = cefpython.WindowInfo()
        windowInfo.SetAsChild(self.GetHandleForBrowser())
        self.browser = cefpython.CreateBrowserSync(windowInfo,
                browserSettings=g_browserSettings,
                navigateUrl=url)

        self.clientHandler.mainBrowser = self.browser
        self.browser.SetClientHandler(self.clientHandler)

        jsBindings = cefpython.JavascriptBindings(
            bindToFrames=False, bindToPopups=True)
        jsBindings.SetFunction("PyPrint", PyPrint)
github cztomczak / cefpython / src / linux / binaries_64bit / deprecated / wxpython.py View on Github external
url = "file://"+GetApplicationPath("wxpython.html")
            # Test hash in url.
            # url += "#test-hash"

        self.CreateMenu()

        # Cannot attach browser to the main frame as this will cause
        # the menu not to work.
        # --
        # You also have to set the wx.WANTS_CHARS style for
        # all parent panels/controls, if it's deeply embedded.
        self.mainPanel = wx.Panel(self, style=wx.WANTS_CHARS)

        # Global client callbacks must be set before browser is created.
        clientHandler = ClientHandler()
        cefpython.SetGlobalClientCallback("OnCertificateError",
                clientHandler._OnCertificateError)
        cefpython.SetGlobalClientCallback("OnBeforePluginLoad",
                clientHandler._OnBeforePluginLoad)
        cefpython.SetGlobalClientCallback("OnAfterCreated",
                clientHandler._OnAfterCreated)

        windowInfo = cefpython.WindowInfo()
        # Must show window otherwise GetHandle() returns 0
        self.Show()
        cefpython.WindowUtils.InstallX11ErrorHandlers()
        windowInfo.SetAsChild(self.mainPanel.GetHandle(),
                              [0,0,0,0])
        # Linux requires adding "file://" for local files,
        # otherwise /home/some will be replaced as http://home/some
        self.browser = cefpython.CreateBrowserSync(
            windowInfo,
github carlosperate / ardublockly / start_cef.py View on Github external
self.SetSize(size)

        if not url:
            url = "http://localhost:8000/ardublockly/index.html"

        # Also have to set wx.WANTS_CHARS style for all parent panels/controls
        self.mainPanel = wx.Panel(self, style=wx.WANTS_CHARS)

        # Global client callbacks must be set before browser is created.
        self.clientHandler = ClientHandler()
        cefpython.SetGlobalClientCallback("OnCertificateError",
                self.clientHandler._OnCertificateError)
        cefpython.SetGlobalClientCallback("OnBeforePluginLoad",
                self.clientHandler._OnBeforePluginLoad)
        cefpython.SetGlobalClientCallback("OnAfterCreated",
                self.clientHandler._OnAfterCreated)

        windowInfo = cefpython.WindowInfo()
        windowInfo.SetAsChild(self.GetHandleForBrowser())
        self.browser = cefpython.CreateBrowserSync(
            windowInfo,
            browserSettings=g_browserSettings,
            navigateUrl=url)

        self.clientHandler.mainBrowser = self.browser
        self.browser.SetClientHandler(self.clientHandler)

        jsBindings = cefpython.JavascriptBindings(
            bindToFrames=False, bindToPopups=True)
        jsBindings.SetFunction("PyPrint", PyPrint)
        jsBindings.SetProperty("pyProperty", "This was set in Python")
github rentouch / cefkivy / cefkivy / browser.py View on Github external
Clock.schedule_interval(cef_loop, 0)

        settings = {
                    #"debug": True,
                    "log_severity": cefpython.LOGSEVERITY_INFO,
                    #"log_file": "debug.log",
                    "persist_session_cookies": True,
                    "release_dcheck_enabled": True,  # Enable only when debugging.
                    "locales_dir_path": os.path.join(md, "locales"),
                    "browser_subprocess_path": "%s/%s" % (cefpython.GetModuleDirectory(), "subprocess")
                }
        cefpython.Initialize(settings, switches)

        windowInfo = cefpython.WindowInfo()
        windowInfo.SetAsOffscreen(0)
        cefpython.SetGlobalClientCallback("OnCertificateError", self.OnCertificateError)
        self.browser = cefpython.CreateBrowserSync(windowInfo, {}, navigateUrl=self.url)

        # Set cookie manager
        cookie_manager = cefpython.CookieManager.GetGlobalManager()
        cookie_path = os.path.join(resources, "cookies")
        cookie_manager.SetStoragePath(cookie_path, True)

        self.browser.SendFocusEvent(True)
        ch = ClientHandler(self)
        self.browser.SetClientHandler(ch)
        self.set_js_bindings()
        self.browser.WasResized()
        self.bind(size=self.realign)
        self.bind(pos=self.realign)
        self.bind(keyboard_mode=self.set_keyboard_mode)
        if self.keyboard_mode == "global":