tkhtml is the home page for one of the Tk HTML widgets that renders HTML into formatted text with hyperlinks. It is a compiled extension.

As of late winter 2005, Dan Kennedy is revitalizing tkhtml [L1 ]. The new version of tkhtml is tkhtml3, which has its own wiki page.

"Which HTML renderer?" [L2 ]

this revision is possibly the dividing line in the repository between versions 2 and 3.

Here is what I did to get it working with tcl8.4.19 and tk8.4.19 on RHEL

Unfortunately it starts with the build of both tcl and tk. For each one of these I did the following:

Build TCL 8.4.19

  cd tcl8.4.19/unix
  ./configure --enable-shared=no
  mkdir static
  mv libtcl8*.a static
  make clean
  ./configure --enable-shared=yes
  make install
  cp static/* /usr/local/lib

Build TK 8.4.19

  cd tk8.4.19/unix
  ./configure --enable-shared=no
  mkdir static
  mv libtk8*.a static
  make clean
  ./configure --enable-shared=yes
  make install
  cp static/* /usr/local/lib

OK now you have a build tree to build against. Untar the tkhtml.tar.gz

  cd htmlwidget

Replace the following line in configure




Then you should be able to do this...

  mkdir ../bld
  cd ../bld
  ../htmlwidget/configure \
    --prefix=/home/sklass/perforce/dev/tools/tcl/Linux/x86_64 \
    --with-tcl=/home/sklass/rpm/BUILD/x86_64/tcl8.4.19 \
    --with-tk=/home/sklass/rpm/BUILD/x86_64/tk8.4.19 --with-x --enable-shared

  make install
  make install-libs

Done - it works on both i386 and x86_64

As always YMMV.

It appears that Tkhtml depends on Tk 8.0-8.3 . Pointers to modifications for Tk 8.4 or newer would be appreciated.

It does work with Tk 8.4 (recent CVS sources), with non-threaded build. But with threaded build I'm encountering misterious segfaults. Victor Wagner

Update 28.12.04. I've fixed problem with threaded build. It was related to mixed use of Tcl_Alloc and malloc and Tcl_Free and free respectively. Patches are available in my Debian package repository at Victor Wagner

Has anyone done any new versions of the Windows DLL? Seems to also show occasonal windows errors with current builds of TCL. A pointer to the latest DLL build available would be appreciated. {Daniel B.] ---

The author writes, on the tkhtml mailing list, that he is working on making the tkhtml cvs accessible as well as setting up a new web site about tkhtml.

Does tkhtml only do HTML rendering, or is there actual code for acting as a WWW client in the widget? I can't tell from the web site.

Only rendering - see below for www clients created using tkHTML.

During late 2003, the author of tkhtml wrote on the tkhtml mailing list:

 > I've seen recent postings to news:comp.lang.tcl about people having all
 > sorts of bug fixes and enhancements for this widget and now this week
 > we see some uploaded files here for the widget.
 > Has anyone contacted the original author to see if there would be interest
 > in creating an project, getting tkhtml source into it, then letting
 > people loose to start fixing and upgrading it?

 Anybody who wants to undertake the task of starting a project
 for tkhtml has my blessing.

 Or if is too slow for you, I can put the code on the [CVS] server
 at and turn folks loose on it there.

See (or [L3 ]; also, Victor Wagner has a recent image [L4 ] of the sources) for the cvs server machine mentioned.

Note that TkHTML uses LGPL.

2003-11-13 - In late 2002 D. Richard Hipp released the files that he wrote to the public domain. The remaining LGPLed file htmlexts.c was written by Peter MacDonald, and he has indicated that this will be re-licensed in the next release. (New release with some simple CSS support still a few months off at least apparently)

Thanks to both of them for the great work and for releasing it with a license compatible with the Tcl/Tk core! Hopefully we'll see TkHTML included in the Tk distribution some time. (others have mentioned that this is on the cards..)

Kitten, a compilation of extensions for the Tclkit user, includes compiled versions of tkhtml for Linux, Solaris, and Windows.

The ActiveTcl Batteries included distribution includes tkhtml [L5 ].

TkHTML is one of the numerous packages in the Tcl community which has its own pecular build requirements. Be certain to read carefully the COMPILE.txt instructions - and take their instructions literally ! You do NOT just do a compile; make ; make install on this package!

  1. You have to build in a directory OTHER than in the source directory.
  2. You have to be in that directory, and then invoke the source directory's configure
  3. You MUST specify the --with-tcl and --with-tk flags, pointing to the source tree
  4. You may very well have to modify the Makefile to do things like add -R flags, flags for locating the libraries for sockets, etc.

Neil Madden has provided a neat little 5 line .sig that points one to this wiki - see the code at Simple Tkhtml web page displayer.

Detlef Groth has written a snit::widget wrapper for the tkhtml widget called snitbrowser. snitbrowser is also used inside the Tcl-documentation tool dgHelpBrowser.

kroc has written a Help.kit with Tkhtml.

TkHTML shares its code base with BrowseX; the latter uses TkHTML, and Peter MacDonald regularly updates the TkHTML CVS repository.

LV We should determine which tkhtml cvs repository Peter MacDonald is updating regularly and mention that here.

A mailing list for discussing D. Richard Hipp's Tk widget for rendering HTML used to exist, but it appears to have been deleted (along with all archives and code updates and enhancmenets) during February or March 2007.

 What: Hipp miscellaneous widgets
 Description: Author has a variety of software available.
        A Tree and Notebook widget written in pure Tcl/Tk code is available.
        Also there is a new tk_messageBox which uses color icons
        and tkhtml, an HTML widget for Tcl/Tk.
        There is a DLL for the TkHTML widget built using the Tcl 8.x
        Stub library, as well as a shared library for RedHat Linux 6.0.
        Support continues to improve - support for table, script and
        applet tags recently added.
        See cvs -d :pserver:[email protected]:/tkhtml
        for the source code.
        Note that the TkHTML widget is distributed as GPL.
 Updated: 11/2004
 Contact: mailto:[email protected] (D. Richard Hipp)

 What: Scout
 Description: WWW browser which uses tkhtml .
 Updated: 08/2001
 Contact: mailto:[email protected]

 What: Tixapps
 Description: Suite of development applications that run with
        Tcl/Tk/Tix or Python/Tkinter/Tix.  Includes an inspector,
        debugger and GNU texinfo browser.
        The code includes Python wrappers for TkHTML and TkTable.
        Currently at version 1.6 .
 Updated: 06/2002
 Contact: See web site.

 What: VAD (Visual Ada Developer)
 Description: Tcl/Tk oriented Ada-95 GUI builder, portable to different
        platforms such as Windows, unix, MacOS, and OS/2 .  You can use
        it as an IDE for any Ada-95 (C, C++, Tcl) project.
        Uses GNAT, TASH, RAPID, Tcl/Tk 8.x, Img, icons, Help System,
         TkPaint, BWidgets, mcListBox, mComboBox, Tktable, ftp_library, csh,
         snack, BLT, itcl, Tix, QuickTimeTcl, XanimTcl, Tcl-gtk, Oratcl,
         XBit, Tkogl, tom, Vtktcl, Tkhtml, Fve, August, ASED, TclDOM, Tclxml
         Whiteboard, TkMC, tkxmlive, IDL_To_Ada.
        Currently at version 6.0 .
 Updated: 08/2002
 Contact: See web site

 What: WebSamba package repository
 Description: A variety of packages for Tcl/Tk 8.4a3, working with
        Windows and RedHat 7.1.  Includes BLT, Snack, Tix, COST,
        TclX, Tktable, Img, Tkhtml, itcl, and TkOgl.
 Updated: 10/2001
 Contact: mailto:[email protected] ) (Leonid Dulman)

 What: browser
 Description: A wrapper around TkHTML with default bindings and functionality
        to create simple web browsing widgets.
        Currently at version 0.1 .
 Updated: 03/2002
 Contact: mailto:[email protected] (Neil Madden)

NEM: Note that the above code hasn't been touched for a while. I did spend quite a lot of time improving this, but apparently I neglected to upload the changes to sourceforge. I have no idea where the newer code is now (probably lost). Somebody created a snit wrapper on this wiki which has approximately the same functionality as my package, and is probably a better starting point.

 What: kitten
 Description: Kitten is a tclkit collection of Tcl/Tk extensions aimed at
        reducing the work a developer has to do while developing a
        scripted document.  It contains scripting extensions like tcllib and
        BWidgets, as well as Expect, itcl/itk/iwidgets/tkhtml, and others.
        Binary extensions are compiled for Windows, Linux, and Solaris as
 Updated: 07/2001
 Contact: See web site.

EKB I found this post from comp.lang.tcl by Victor Wagner to be invaluable:

 I've build Tkhtml widget 2.0 from CVS and find out that it works very
 strange way. hv.tcl works and processes hyperlinks fine, but
 when I'm trying to use html widget in my code, mouse click events are

 It took me about half of day to find out that HtmlClip widget is
 silently created when page is loaded into html widget, and silently
 intercerts all events except on tiny border around widget.

 Also mouse wheel scrolling is not supported.

 I think that set of default bindings should be included into Tkhtml
 package, just as it is done for core Tk widget.

 At least following bindings should appear

 1. <Motion> binding which would change cursor to hand when over
 hyperlink (such binding already present in the hv.tcl code)
 2. <Button-1> binding to invoke a command, specified with -hyperlinkcommand
  widget option
 3. <Mouse-Wheel> bindings (for instance, copied from text widget)

 Here is an prototype for this bindings:
 # Change cursor to hand if over hyperlink
 # Copied from hv.tcl

 bind HtmlClip <Motion> {
  set parent [winfo parent %W]
  set url [$parent href %x %y]
  if {[string length $url] > 0} {
    $parent configure -cursor hand2
  } else {
    $parent configure -cursor {}


 # Mouse Wheel bindings
 # Cut'n'pasted from Text widget binding

 if {[string equal [tk windowingsystem] "classic"]
        || [string equal [tk windowingsystem] "aqua"]} {
    bind HtmlClip <MouseWheel> {
        %W yview scroll [expr {- (%D)}] units
    bind HtmlClip <Option-MouseWheel> {
        %W yview scroll [expr {-10 * (%D)}] units
    bind HtmlClip <Shift-MouseWheel> {
        %W xview scroll [expr {- (%D)}] units
    bind HtmlClip <Shift-Option-MouseWheel> {
        %W xview scroll [expr {-10 * (%D)}] units
 } else {

    bind HtmlClip <MouseWheel> {
        %W yview scroll [expr {- (%D / 120) * 4}] units


 if {[string equal "x11" [tk windowingsystem]]} {
    # Support for mousewheels on Linux/Unix commonly comes through mapping
    # the wheel to the extended buttons.  If you have a mousewheel, find
    # Linux configuration info at:
    bind HtmlClip <4> {
        if {!$tk_strictMotif} {
            %W yview scroll -5 units
    bind HtmlClip <5> {
        if {!$tk_strictMotif} {
            %W yview scroll 5 units


 # Invoke widget hyperlink command on the hyperlink
 # Invented by myself
 bind HtmlClip <1> {
        set parent [winfo parent %W]
        set url [$parent href %x %y]
        if {[string length $url]} {
                eval [$parent cget -hyperlinkcommand] $url