1

I use wxpthon library to write UI program in CentOS system wx.html2 . WebView control, the following error is prompted:

  File "main.py", line 143, in <module>
    frame = DemoFrame()
  File "main.py", line 101, in __init__
    self._mainPanel = MainPanel( self )
  File "main.py", line 17, in __init__
    self.view = wx.html2.WebView.New(self)
NotImplementedError

Part of my code is like this:

class MainPanel( sp.ScrolledPanel ):
    #Main Panel
    def __init__( self, parent ):
        sp.ScrolledPanel.__init__( self, parent=parent )
        self.SetupScrolling()
        self.view = wx.html2.WebView.New(self)
        self.view.LoadURL( "http://www.baidu.com" )

CentOS version:CentOS Linux release 8.2.2004 (Core)

Python version: Python 3.6.8

wxPython version: 4.1.1 gtk3 (phoenix) wxWidgets 3.1.5

puwow
  • 11
  • 1
  • Are you sure you are importing it separately? i.e. `import wx.html2` – Rolf of Saxony Feb 19 '21 at 19:45
  • Yes, I'm sure.I have been writing the mswin platform similar applications, I query the relevant information, the default, centos system installed the Firefox browser, Firefox browser based on Gecko kernel code, and wxPython web site seems did not mention the wx. Html2. WebView support for the kernel, so I may need to compile WebKitGTK + by myself, in order to meet the module of its kernel calls, of course this is only for my guess, has not been verified. – puwow Feb 20 '21 at 12:46

1 Answers1

2

NotImplementedError means that wxPython was compiled without wx.html2 support. The most likely cause of this on Linux is that the WebKit development packages were not present when you installed/compiled wxPython. To resolve this, install the WebKit2 development package and reinstall wxPython. On CentOS 8, the WebKit2 development package is webkit2gtk3-devel, so install it with the package manager, e.g., yum install webkit2gtk3-devel and then uninstall/reinstall wxPython. Note: you may have to also clear the pip cache so that it won't re-use the previously compiled version of wxPython.