Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def OnClose(self, event):
# Remember to destroy all CEF browser references before calling
# Destroy(), so that browser closes cleanly. In this specific
# example there are no references kept, but keep this in mind
# for the future.
self.Destroy()
# On Mac the code after app.MainLoop() never executes, so
# need to call CEF shutdown here.
if platform.system() == "Darwin":
chrome.Shutdown()
wx.GetApp().Exit()
# in this example we dont want reload button
self.GetReloadButton().Hide()
self.SetSizer(sizer)
self.Fit()
class MyApp(wx.App):
def OnInit(self):
frame = MainFrame()
self.SetTopWindow(frame)
frame.Show()
return True
if __name__ == '__main__':
chrome.Initialize()
print('sample3.py: wx.version=%s' % wx.version())
app = MyApp()
app.MainLoop()
# Important: do the wx cleanup before calling Shutdown
del app
# On Mac Shutdown is called in OnClose
if platform.system() in ["Linux", "Windows"]:
chrome.Shutdown()
def OnClose(self, event):
# Remember to destroy all CEF browser references before calling
# Destroy(), so that browser closes cleanly. In this specific
# example there are no references kept, but keep this in mind
# for the future.
self.Destroy()
# On Mac the code after app.MainLoop() never executes, so
# need to call CEF shutdown here.
if platform.system() == "Darwin":
chrome.Shutdown()
wx.GetApp().Exit()
def OnClose(self, event):
# Remember to destroy all CEF browser references before calling
# Destroy(), so that browser closes cleanly. In this specific
# example there are no references kept, but keep this in mind
# for the future.
self.Destroy()
# On Mac the code after app.MainLoop() never executes, so
# need to call CEF shutdown here.
if platform.system() == "Darwin":
chrome.Shutdown()
wx.GetApp().Exit()
self.Destroy()
# On Mac the code after app.MainLoop() never executes, so
# need to call CEF shutdown here.
if platform.system() == "Darwin":
chrome.Shutdown()
wx.GetApp().Exit()
class MyApp(wx.App):
def OnInit(self):
frame = MainFrame()
self.SetTopWindow(frame)
frame.Show()
return True
if __name__ == '__main__':
chrome.Initialize({
"debug": True,
"log_file": "debug.log",
"log_severity": chrome.cefpython.LOGSEVERITY_INFO,
"release_dcheck_enabled": True,
# "cache_path": "webcache/",
})
print('[sample1.py] wx.version=%s' % wx.version())
app = MyApp(False)
app.MainLoop()
# Important: do the wx cleanup before calling Shutdown
del app
# On Mac Shutdown is called in OnClose
if platform.system() in ["Linux", "Windows"]:
chrome.Shutdown()
chrome.Initialize()
if platform.system() == "Linux":
# CEF initialization fails intermittently on Linux during
# launch of a subprocess (Issue 131). The solution is
# to offload cpu for half a second after Initialize
# has returned (it still runs some stuff in its thread).
import time
time.sleep(0.5)
print('sample2.py: wx.version=%s' % wx.version())
app = MyApp(False)
app.MainLoop()
# Important: do the wx cleanup before calling Shutdown
del app
# On Mac Shutdown is called in OnClose
if platform.system() in ["Linux", "Windows"]:
chrome.Shutdown()
def __init__(self, parent, url):
wx.Frame.__init__(self, parent)
self.sizer = wx.BoxSizer(wx.HORIZONTAL)
if HAS_CHROME:
self.browser = browser.ChromeWindow(self, url)
else:
self.browser = browser.WebView.New(parent=self, url=url, name='LalkaWebViewGui')
self.sizer.Add(self.browser, 1, wx.EXPAND)
self.SetSizer(self.sizer)
self.Show()
self.SetFocus()
if __name__ == '__main__':
chrome.Initialize({
"debug": True,
"log_file": "debug.log",
"log_severity": chrome.cefpython.LOGSEVERITY_INFO,
"release_dcheck_enabled": True,
# "cache_path": "webcache/",
})
print('[sample1.py] wx.version=%s' % wx.version())
app = MyApp(False)
app.MainLoop()
# Important: do the wx cleanup before calling Shutdown
del app
# On Mac Shutdown is called in OnClose
if platform.system() in ["Linux", "Windows"]:
chrome.Shutdown()
def __init__(self):
wx.Frame.__init__(self, parent=None, id=wx.ID_ANY,
title='cefwx example1', size=(800,600))
self.cefWindow = chrome.ChromeWindow(self,
url=os.path.join(os.path.dirname(os.path.abspath(__file__)),
"sample1.html"))
sizer = wx.BoxSizer()
sizer.Add(self.cefWindow, 1, wx.EXPAND, 0)
self.SetSizer(sizer)
self.Bind(wx.EVT_CLOSE, self.OnClose)
def OnSelChanged(self, event):
self.item = event.GetItem()
url = self.tree.GetItemText(self.item)
if url and url != ROOT_NAME:
cefPanel = chrome.ChromeCtrl(self.tabs, useTimer=True, url=str(url))
self.tabs.AddPage(cefPanel, url)
self.tabs.SetSelection(self.tabs.GetPageCount()-1)
event.Skip()