Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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",
# 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)
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(
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)
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)
# 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)
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,
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")
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":