我使用 wxpython 创建了自定义最大化框架。在面板顶部,自定义关闭按钮和底部 cefpython 浏览器需要包含。为了分离,我使用了 BoxSizer。CreateBrowserSync 正在返回浏览器对象,因此,我收到了错误消息。
错误:
[CEF Python] ExceptHook: catched exception, will shutdown CEF
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/wx/core.py", line 2116, in Notify
self.notify()
File "/usr/local/lib/python2.7/dist-packages/wx/core.py", line 3245, in Notify
self.result = self.callable(*self.args, **self.kwargs)
File "wxpython.py", line 162, in embed_browser
self.sizer.Add(self.browser, 1, wx.EXPAND)
TypeError: Sizer.Add(): arguments did not match any overloaded call:
overload 1: argument 1 has unexpected type 'cefpython_py27.PyBrowser'
overload 2: argument 1 has unexpected type 'cefpython_py27.PyBrowser'
overload 3: argument 1 has unexpected type 'cefpython_py27.PyBrowser'
overload 4: argument 1 has unexpected type 'cefpython_py27.PyBrowser'
overload 5: argument 1 has unexpected type 'cefpython_py27.PyBrowser'
overload 6: argument 1 has unexpected type 'cefpython_py27.PyBrowser'
overload 7: argument 1 has unexpected type 'cefpython_py27.PyBrowser'
overload 8: argument 1 has unexpected type 'cefpython_py27.PyBrowser'
overload 9: argument 1 has unexpected type 'cefpython_py27.PyBrowser'
代码
window_info = cef.WindowInfo()
(width, height) = self.browser_panel.GetClientSize().Get()
assert self.browser_panel.GetHandle(), "Window handle not available yet"
window_info.SetAsChild(self.browser_panel.GetHandle(),
[1, 1, width, height])
self.browser = cef.CreateBrowserSync(window_info,
url="https://www.google.com/")
self.sizer = wx.BoxSizer(wx.VERTICAL)
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.sizer.Add(closeBtn, 0, wx.ALIGN_RIGHT | wx.ALL)
sizer.Add(self.browser, 1, wx.EXPAND)
self.SetSizer(sizer)
如何将 cefpython 浏览器对象绑定到 wxpython 中的 BoxSizer。如果有其他替代解决方案,请告诉我。