wxHTML for Beginners
By Abhijit Belapurkar2004-10-30
Building Basic Browser Functionality with wxPython
Many applications use HTML for reporting and online help, among other things. Embedding a Web browser in your application eliminates the need to worry about which browser a client uses to view your pages, and also allows you to create custom tags that tie the HTML page back to your application. For example, for the help system in an IDE, a user could browse a function reference where you have created custom tags, and when the user clicks on the function name, the function call could be inserted into the user's code.
Typically, most applications solve most browser problems by keeping HTML simple -- writing, as it were, to the lowest common denominator. Even in this case, however, problems with fonts and layout still persist, as well as the pain of testing of your application when new browsers are released and existing browsers are upgraded. The alternative -- supporting only one browser -- isn't usually a user-friendly solution.
The obvious solution is to embed your own HTML-rendering widget in your application. Of course, writing such a widget from scratch is a large job, so it seems logical to turn to a pre-packaged solution.
There are a number of choices in the commercial world, as well as a few open source packages (see Resources later in this article). This article will show you how to use the wxHtml widget distributed as part of the wxWindows package, with Python as the language of choice for the bindings (C++, Perl, and other languages are supported as well).
This article assumes a basic knowledge of wxPython, although experienced Python developers with no wxPython experience should be able to hit the ground running. In this article we will create a standalone browser application, while keeping the architecture simple enough that it would be a simple task to migrate the browser functionality into an existing application.
Tutorial Pages:
» Building Basic Browser Functionality with wxPython
» The World's Most Basic Browser
» Resources
First published by IBM DeveloperWorks
