This page is about RenderTk, a package that tries to "emulate" a *tiny* part of Tk, and "render" it as HTML. Emphasis should be given to "tiny" (much of Tk is not supported), and "render". (The Tk UI is converted in HTML tags; the resulting HTML does not function as the original Tk code. It only "draws" the Tk UI.)

Why RenderTk?

I needed a way to "convert" a Tk UI into an HTML UI (using AngularJS). I would like very much to use WubTk, but I had the following limitations:

I was not using Wub, I was using Apache Rivet, inside the Apache 2 web server.

Tk was not available, I had no X Server the Apache 2 server could connect to.

Initially, I tried to modify WubTk, in order to remove dependencies to Wub and Tk, and I ended up writing RenderTk. So, RenderTk was inspired by WubTk, and to some extent it borrowed its implementation, as it started from the WubTk implementation.

What is new

RenderTk tries to mimic Tk as much as possible. This means that I didn't like the fact that WubTk used "grid" in a strange way, and you have to use cell coordinates to all widgets. This means that you can never re-use the same Tk code. So, I decided that the grid command must be emulated, and I did it: RenderTk has a (partial) implementation of grid in Tcl. I did this by translating the C code from Tk internals into Tcl. Maybe not the fastest approach, but for sure the most compatible... :-)

What is missing

Almost everything. As a start, interaction of any kind with the rendered UI.

How it works

Instead of creating Tk widgets, the package creates widgets using TclOO objects. Each widget is a TclOO class, but if you look more closely, all classes inherit RenderTk::classes::widget, with different instantiation. All options are kept inside each object (yes, even non-Tk ones), and during rendering, if an option is present, it is mapped to the output. Everything is managed by the _tag_attributes_map list, which maps options (minus the starting "-" character) to strings. For example, {bg-color="%V" background} maps the value of -background (if not empty) to {bg-color="<value>"}. %V stands for the value of the option.