1

I have a very very specific problem. I am trying to figure out a way to embed an HTML brower in my app, in order to show some generated HTML content with included javascript.

I tried to do it with wx.html2, but the javascript part just seems to not work. So I decided to give a try to CEFPython by taking example of the provided wxPython.py demo.

At first, it worked great in the UI I designed.

BUT, the problem is that this UI is intended to be called from another application, as a sort of "plug-in UI". And when launching my wxPython UI from this application, it crashes as soon as cef is initialized (through:

sys.excepthook = cef.ExceptHook
settings = {
    "debug": True,
    "log_severity": cef.LOGSEVERITY_INFO,
   "log_file": "debug.log",
}
cef.Initialize(settings=settings)
app = CefApp(False)
app.MainLoop()
del app
cef.Shutdown()

I keep getting this error:

Python exception: AttributeError
'module' object has no attribute 'argv'
Traceback (most recent call last):
  File "<string>", line 248, in <module>
  File "<string>", line 36, in main
  File "cefpython_py27.pyx", line 626, in cefpython_py27.Initialize 
(cefpython_py27.cpp:99136)
AttributeError: 'module' object has no attribute 'argv'

So in the end I have 2 questions:

  1. is there a way with wx.html2 to show HTML content embedding javascript
  2. if not, do you have a clue of what would cause the launched UI to crash? I guess it's a threading matter but I'm not even sure.

Please excuse my english mistakes by the way, as I'm not native.



ThylowZ
  • 55
  • 7

1 Answers1

1

It seems that your Python environment doesn't behave in a standard manner, you don't provide details how is your Python code called.

The error in cefpython is thrown on this line:

if "--debug" in sys.argv:
    application_settings["debug"] = True

https://github.com/cztomczak/cefpython/blob/bbf3597ba47f72db66cf304ab8eb3ccfc3a7130c/src/cefpython.pyx#L631

You have to find out why your Python didn't define "sys.argv". You can easily fix this with code like this: sys.argv = [] before calling cef.Initialize, however you may still encounter other issues due to your non-standard Python environment.

Czarek Tomczak
  • 20,079
  • 5
  • 49
  • 56
  • Well it seems it solves the problem. Was not sure if such a solution was possible since I'm not very familiar with it. Anyway, thank you for your quick answer. – ThylowZ Mar 09 '18 at 16:17
  • @ThylowZ If that solved your problem then please select the answer as Accepted and give it +1. – Czarek Tomczak Mar 09 '18 at 17:06