How can I get a more fully featured HTML Widget

Although the wx.html.HtmlWindow is not a fully featured browser pane, there are a couple of options for embedding a more fully featured HTML rendering window. If you are on a Windows platform, you can use the class wx.lib.iewin.lEHtml-Window, which is a wxPython wrapper around the Internet Explorer ActiveX control. This allows you to embed an Internet Explorer window directly into your application.

Using the Internet Explorer (IE) control is relatively straightforward and similar to using the internal wxPython HTML window. It has a widget-like constructor, as in the following.

wx.lib.iewin.IEHtmlWindow(self, parent, ID=-1, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0, name='IEHtmlWindow')

Everything here is in keeping with wxPython widgets, the parent is the parent window, and the ID is the wxPython ID. There are no useful style flags for an IE window. To load HTML into the IE component, use the method LoadString (html), where the html parameter is an HTML string to display. You can load from an open file, or anything that is a Python file object, using the method Load-Stream(stream), or from a URL using the method LoadString(URL). You can retrieve the text being displayed with the method GetText(asHTML). The asHTML parameter is a Boolean. If True, the text is returned in HTML, otherwise, it's just returned as a text string.

On other platforms, you can try the wxMozilla project (http://wxmozilla., which attempts to create a wxPython wrapper around the Mozilla Gecko renderer. Currently, the project is still in beta. The wxPython extension for this project has an installer for Windows and Linux, with Mac OS X support in progress.

Was this article helpful?

0 0

Post a comment