Using wx.html.HtmlHelpController() in Phoenix

After converting an application from Python 2.7/Classic to 3.4/Phoenix, (using Windows, OS X is OK) its help file, displayed using a class derived from wx.html.HtmlHelpController() showed all the html tags as text instead of interpretting them, see attached, although with Robin’s stand alone wx.tools.helpviewer.py in Phoenix the file renders correctly.
Reducing the app to the bare essentials to isolate this, I eventually discovered that the import wx.html that is necesary for using HtmlHelpController must be done before the main wx.App is defined and I was doing the import inside the derived class. You can see this effect if you move the location of the import in helpviewer.py.

Not a serious problem - now I know the answer! - but I thought I would report it here to save someone’s time in case anyone else runs into this.

HtmlHelpWrong.png

HtmlHelpGood.png

···


Regards

David Hughes
Forestfield Software

David Hughes wrote:

After converting an application from Python 2.7/Classic
to 3.4/Phoenix, (using Windows, OS X is OK) its help file, displayed using a class derived from wx.html.HtmlHelpController() showed all the html tags as text instead of interpretting them, see attached, although with Robin’s stand alone wx.tools.helpviewer.py in Phoenix the file renders correctly.
Reducing the app to the bare essentials to isolate this, I eventually discovered that the import wx.html
that is necesary for using HtmlHelpController must be done before the main wx.App is defined and I was doing the import inside the derived class. You can see this effect if you move the location of the import in helpviewer.py.

Not a serious problem - now I know the answer! - but I thought I would report it here to save someone’s time in case anyone else runs into this.

I’ve seen this type of thing in a couple other places too. If it’s the same thing then it has to do with when the wx DLL containing the C++ wxHtmlHelpController is loaded into memory. In a nutshell there is some
type information about the classes that wx uses for some advanced features, and the integration of all that static information is normally
only done when the application starts up. In Classic I worked around this by adding some code to reintegrate that meta info when some of the non-core modules are imported. I’ll check if I can do something similar
in Phoenix. (Actually, I’ve probably done it somewhere for Phoenix already, so I’ll just need to add it for wx.html too.)

···


Robin Dunn

Software Craftsman

http://wxPython.org