Porting a Tk GUI to A Web Browser

In comp.lang.tcl, I asked: "Does anyone here have any thoughts or pointers into the Wiki, or to papers that might help us port our current Tcl-Tk GUIs to a browser without re-coding in Java?"

I received the following suggestions:

  • Manfred Rosenberger ever tried Woof!
  • Marty Backe suggested tcljava and swank, "particularly the latter." CL observes that Swank is for use with the Jacl part of Tcljava.
  • Tom Poindexter suggested: "You might try WeirdX, it's an X11 server written in Java, and runs as a browser applet. I've used this in the past to deliver Tcl/Tk applications for internal users. It's suitable for running on fast, secure networks."
  • Tom also suggests: "Proxy Tk would also be an idea, but to my knowledge, it never made it into public consumption". Bryan Oakley also offered the same suggestion, continuing: "The short summary is, you write tk on the server which drives a thin client that translates the tk commands into java widgets in the client. The software isn't available, but it looks like a fairly straight-forward thing to reinvent. Unless your guis are trivial, it may take less effort to reinvent proxytk than it would be to recode all of the GUIs in Java."
  • Several folks suggested VNC. As of 2006, CL is doing a lot of work with VNC-in-a-browser; expect this to become public in late September.
  • Donal Fellows suggested: "If you end up having to do Java GUIs, start by porting the Tk geometry managers to Java as the standard ones are not really very good (GridBagLayout sucks a lot more than you might think at first. Trust me.) That'll save you much frustration."
  • Roy Terry suggested: "You can run Tcl/Tk as an activeX object using TclControl. I believe, but haven't done the work, that you could also package the tclcontrol along with the needed Tcl/Tk dlls, etc. into a CAB file and have the whole thing download seamlessly on Windows." A paper [L1 ] provides details.
  • CL also believes that good engineering judgment in such a matter depends on details. Is the GUI just a buttons-and-entry form-oriented office-automation sort of thing, or does it involve a lot of canvas sophistication? What network characteristics can be assumed? What security and licensing models are involved?
  • Roy Keene suggested: It should be possible to emulate the Tk functionality in Tcl, and also provide an HTML rendering engine for the psuedo-Tk widgets in HTML. An incomplete example [L2 ] [L3 ] is available for examination. A Tkweb screenshot ( http://www.rkeene.org/projects/tkweb/tkweb-test1-2.png ) is also available. This method is also discussed by Wilfred J. Hansen [L4 ] .
  • Æjaks Although not directly compatible with Tk, Æjaks provides a very similar programming model.
  • By 2010, HTML5 has caught up sufficiently to offer canvas, SVG, and other interesting advances that duplicate parts of Tk's style.

Eventually this goes in the same direction: Matthias Hoffmann - Thoughts And Ideas|Generating HTML with commands styled after Tk??

Googie - 2011-05-28 - I was playing a little with ajax lately (using jquery) and I believe Tk can be implemented (more or less accurately) using tools like jquery or dojo or something similar for frontend, then some object orientation package on Tcl side (TclOO most probably) + json::write from Tcllib. What do you guys think?

Martin Cleaver - 2011-12-16 - believes that transpiling tcltk into coffeescript and html5 would be a worthy goal.

FireTcl - 2015-08-18 23:53:41

I developed FireTcl. It's a framework that embeds Tcl into Firefox.

It uses behind the scenes the XPCOM component js-ctypes, and coroutines for emulating interactivity with the browser (execute javascript, manipulate the DOM,...)


Jeff Smith = 2017-12-18: Check out CloudTk for viewing Tk applications (unmodified) in a modern web browser.

chw 2019-02-17: Check out the jsmpeg SDL video driver with undroidwish, see https://www.androwish.org/index.html/wiki?name=jsmpeg+SDL+Video+Driver for details.