I ported my PyQt6 app to wxPython and have it working in a VS Code virtual environment, using Python 3.12.9 and run within VS Code. The PyQt6 app that is built using pyinstaller works fine.
When I package the wx version of the app, using pyinstaller, everything works except for the wx.html2 browser which causes a javascript error.
Pages with no javascript render correctly. I suspect there is some file(s) that pyinstaller is missing when it builds the package. So I reviewed the files in the directory [dist\main_internal\wx] and find the following 13 files:
I tried copying the files from the .venv\Lib\site-packages\wx to the build’s _internal\wx directory hoping to be able to find the missing file and that didn’t resolve the problem.
Looking through the various postings, I tried adding: backend=wx.html2.WebViewBackendEdge) to the wx.html2.WebView.New call but this caused the WebView to totally fail on my windows 11 system.
Any suggestion on how to get Javascript working on a pyinstaller installed app?
Thanks in advance,
Tom
SOLVED
This problem was addressed back in 2021, in the post: MS Edge backend for WebView - #10 by cutright.
When I manually copied the file “WebView2Loader.dll” from the .venv\Lib\site-packages\wx directory to the pyinstaller dist\main_internal\wx directory javascript starts working again.
I apologize for not researching more, before posting my question.
Tom
Here is my test code:
import wx
import wx.html2
class MyFrame(wx.Frame):
def init(self, parent, title):
super().init(parent, title=title, size=(950, 535))
sizer = wx.BoxSizer(wx.VERTICAL)
self.SetSizer(sizer)
hsizer = wx.BoxSizer(wx.HORIZONTAL)
sizer.Add(hsizer, 0, wx.EXPAND)
btn1 = wx.Button(self, label='Load Non-Javascript Page')
btn2 = wx.Button(self, label='Load Javascript Page')
hsizer.Add(btn1, 0, wx.EXPAND)
hsizer.Add(btn2, 0, wx.EXPAND)
btn1.Bind(wx.EVT_BUTTON, self.OnBtn1)
btn2.Bind(wx.EVT_BUTTON, self.OnBtn2)
self.webview = wx.html2.WebView.New(self)
sizer.Add(self.webview, 1, wx.EXPAND)
self.webview.LoadURL('http://www.google.com')
self.Show()
def OnBtn1(self, event):
self.webview.LoadURL('http://www.pilotgeek.com')
def OnBtn2(self, event):
self.webview.LoadURL('https://aviationweather.gov/gfa/#obs')
def main():
# Create the wx.App and the frame
app = wx.App(False)
frame = MyFrame(None, f"Test Code")
app.MainLoop()
Main program
if name == “main”:
main()
when run in VS Code, works perfectly. When compiled to exe with pyinstaller, using the command: pyinstaller -w main.py
the non-javascript http page loads fine, but the javascript https page fails to render correctly.
Hope this helps clarify my issue.
This problem was addressed back in 2021, in the post: MS Edge backend for WebView - #10 by cutright.
When I manually copied the file “WebView2Loader.dll” from the .venv\Lib\site-packages\wx directory to the pyinstaller dist\main_internal\wx directory javascript starts working again.
I apologize for not researching more, before posting my question.
Tom