HtmlWindow (wxHTML) Widget

HtmlWindow is the wxWidgets HTML display widget. It can be found in the wx.html module. It is not a full featured browser, and does not support modern html features like CSS, and certainly not JavaScript. However, it can be very useful for laying out and rendering a wide variety of documents, using a well understood markup language. It also has the wonderful special feature of being able to embed wx Widgets in an html page.

HtmlWindow and Form tags

HtmlWindow has no form support, but it can be extended with custom tag handlers. Download this attachment for a sample package implementing support for HTML forms.

Embedding Images in HtmlWindow

HtmlWindow can display inline images in the usual way, by providing a url to the image. However, if you want to be able to use HtmlWindow to display a page with some images, but don't want to have to have the image files on the file system, there are a couple ways to embed images that you have in memory, and can be loaded from python code (or gotten into memory any other way).

The following example demonstrates two ways:

* Using HtmlWindow's ability to show a wx widget on the page, and embedding a wxStaticBitmap. HtmlWindow is expecting to instantiate the class, and there is no way to pass a wx.Bitmap into the constructor, so you need a custom class. If you want to do something more fancy, you can creating new tag handler.

* Using wx.MemoryFSHandler(). HtmlWindow uses wx.FileSystem as an abstraction of the file system to load resources. You can add a MemoryFSHandler to it, and put whatever you want in there. I think this is the cleanest way to do it, and the html is then pretty standard.

Note: in the below code, the html refers to the name of the module that the "Bitmap1" class is defined, which is this file, so you need to name it ImageInHtml.py in order for it to work.