下面是wxpython GUI的指定代码,您可以在其中观察到我使用wx.html2.WebView在面板上呈现 Web。是否可以将相同的代码从webview替换为cefpython?
我还得到了启动自己的框架的cefpython 代码e。我不想打开它自己的框架,而不是它绑定在wxpython 面板上。你可以看到下面的cefpython代码。
1.wxpython GUI代码
import wx
import sys
import wx.html2
def main(args):
app = CefApp(False, args)
app.MainLoop()
class MainPanel(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent=parent)
self.frame = parent
sizer = wx.BoxSizer(wx.VERTICAL)
self.wv = wx.html2.WebView.New(self)
closeBtn = wx.Button(self, label="X", size=(30, 30))
closeBtn.Bind(wx.EVT_BUTTON, self.onClose)
vbox = wx.BoxSizer(wx.VERTICAL)
hbox= wx.BoxSizer(wx.HORIZONTAL)
hbox.Add(closeBtn, 0, flag=wx.ALIGN_RIGHT | wx.ALL)
vbox.Add(hbox, 0, flag=wx.ALIGN_RIGHT | wx.ALL)
self.SetSizer(vbox)
vbox.SetSizeHints(self)
self.SetWindowStyle(wx.STAY_ON_TOP)
sizer.Add(closeBtn, 0, wx.ALIGN_RIGHT | wx.ALL)
sizer.Add(self.wv, 1, wx.EXPAND)
self.SetSizer(sizer)
self.wv.LoadURL("http://google.com")
def onClose(self, event):
dlg = DialogBox()
dlg.ShowModal()
class MyFrame(wx.Frame):
def __init__(self, args):
wx.Frame.__init__(self, None, title="ESSB Demo")
self.url = args
self.browser_panel = MainPanel(self)
self.ShowFullScreen(True)
2.CefPython代码。
from cefpython3 import cefpython as cef
import platform
import sys
def main():
sys.excepthook = cef.ExceptHook # To shutdown all CEF processes on error
cef.Initialize()
cef.CreateBrowserSync(url="https://www.google.com/")
cef.MessageLoop()
cef.Shutdown()
请指教。