Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

making a web app of a tcl/tk program

225 views
Skip to first unread message

Bill Poser

unread,
Nov 27, 2020, 9:45:31 PM11/27/20
to
I have been asked whether it would be possible to make one of my tcl/tk programs available as a web app. Is there a nice, simple way to do this, i.e. something that runs tcl/tk server-side? I have found a number of tutorials on using tcl/tk as a cgi language to generate dynamic web pages, but that isn't what I want to do. Rather, I want a user to be able to go to a web page, click a button, and run my tcl/tk program without having to install tcl/tk on the local machine or download and run a starkit. Any advice? Thanks.

Robert Heller

unread,
Nov 27, 2020, 10:57:41 PM11/27/20
to
There are packages that implement a web server implemented in Tcl, including
the one built into sdx (which could be included in a starkit).

Some notes to think on:

I don't know how much server load (eg number of connections) the pure Tcl
coded "web servers" can handle -- I would suspect that they might not be as
robust, etc. as Apache or other web server deamons. The Tcl coded web server
packages are generally meant for fairly light duty work.

In any case, it is NOT going to be a Tcl/Tk application. ALL of the "Tk" code
will have to be completely *replaced* with served HTML[5] (including Style
Sheets and JavaScript, etc.). This might not be a trivial task.

Additionally:

There have been browser plugins that implemented Tcl/Tk, but I don't know if
any of that is still available. And they might still require downloading and
installing a browser plugin.

The only other option would be a virtual machine that implements a remote
desktop -- you could install your program there and the users would fire up a
web based (?) remote desktop. I *think* this might be possible, but don't
really know.

>
>

--
Robert Heller -- Cell: 413-658-7953 GV: 978-633-5364
Deepwoods Software -- Custom Software Services
http://www.deepsoft.com/ -- Linux Administration Services
hel...@deepsoft.com -- Webhosting Services

Bill Poser

unread,
Nov 27, 2020, 11:39:45 PM11/27/20
to
Thanks, that is informative. It sounds like it won't be easy to do what I have been asked about.
The plugins that I have looked at all seem to date back to the Netscape era and not to have been updated in the last decade, so I don't know how well they will work.

Christian Gollwitzer

unread,
Nov 28, 2020, 2:16:08 AM11/28/20
to
Am 28.11.20 um 03:45 schrieb Bill Poser:
> I have been asked whether it would be possible to make one of my tcl/tk programs available as a web app. Is there a nice, simple way to do this, i.e. something that runs tcl/tk server-side? I have found a number of tutorials on using tcl/tk as a cgi language to generate dynamic web pages, but that isn't what I want to do. Rather, I want a user to be able to go to a web page, click a button, and run my tcl/tk program without having to install tcl/tk on the local machine or download and run a starkit. Any advice? Thanks.
>


There are ways, but with varying mileage and difficulty. There is no way
to get a good web application withour effort, sadly, but depending on
your needs it might still be possible to get something OKish.

1) Aejaks: https://wiki.tcl-lang.org/page/%C3%86jaks
This comes closest to a real web app. But it requires adapting the code,
because it is not 100% compatible to Tk, only similar, plus the Tcl code
runs on a tcljava, an alternative Tcl running on Java, which is also noz
100% compatible

2) CloudTk: This comes closest to running the unmodified program.
http://cloudtk.tcl.tk/ Demonstration on several wiki pages, e.g. try
this one: https://wiki.tcl-lang.org/page/tkEngine or this onw
https://wiki.tcl-lang.org/page/A+symmetric+doodler
Disadvantage, it is not a "real" web application, but it displays the Tk
rendering in a box on the page, like a remote desktop session. It looks
a bit odd and doesn't react so swiftly as an application running locally.

3) Emscripten: This is a compiler which can turn C applications into
Javascript/WASM to run in the browser. There is a usable Tcl version
here: https://aidanhs.github.io/emtcl/ but I'm not sure, if Tk was also
done for emscripten. Theoretically, it should be possible, since whole
QT applications were successfully ported with emscripten

All of these suffer the problem of permanent storage, i.e. if you have,
say, a database application, you must ensure a way to store user data.

Christian

Uwe Klein

unread,
Nov 28, 2020, 4:29:42 AM11/28/20
to
Am 28.11.20 um 03:45 schrieb Bill Poser:
> I have been asked whether it would be possible to make one of my tcl/tk programs available as a web app. Is there a nice, simple way to do this, i.e. something that runs tcl/tk server-side? I have found a number of tutorials on using tcl/tk as a cgi language to generate dynamic web pages, but that isn't what I want to do. Rather, I want a user to be able to go to a web page, click a button, and run my tcl/tk program without having to install tcl/tk on the local machine or download and run a starkit. Any advice? Thanks.
>
There used to be a tcl plugin for browsers around?
https://www.tcl.tk/software/plugin/
( not quite what you want.)

Then This?
https://resources.sei.cmu.edu/library/asset-view.cfm?assetid=6375

Uwe

Donal K. Fellows

unread,
Nov 28, 2020, 4:42:25 AM11/28/20
to
On Saturday, 28 November 2020 at 03:57:41 UTC, Robert Heller wrote:
> I don't know how much server load (eg number of connections) the pure Tcl
> coded "web servers" can handle -- I would suspect that they might not be as
> robust, etc. as Apache or other web server deamons. The Tcl coded web server
> packages are generally meant for fairly light duty work.

Some of them are fairly capable. The key trick is to put a standard web server
in front to handle gatekeeping and static pages (nginx has a good reputation
for such things) and then slot the Tcl web servers in behind that to do the
dynamic pages.

> In any case, it is NOT going to be a Tcl/Tk application. ALL of the "Tk" code
> will have to be completely *replaced* with served HTML[5] (including Style
> Sheets and JavaScript, etc.). This might not be a trivial task.

This is the thing that will take time and effort. However, if the application is
fairly simple or the network between clients and server is fast enough, you can
essentially just replace the actual GUI parts with a Javascript SPA and then
have your networking code be focused on synchronizing the model between
the SPA and the back end Tcl code. For things like forms, that's trivially easy
as you only actually need to communicate when the form is submitted/committed.
For complex applications (such as GUIs for real-time simulations) it's much
trickier as there are many orders of magnitude more communications, including
plenty of asynchronous notifications. Everything's fine providing the messaging
fabric is working… but that breaks rather too easily and it's always for client-side
reasons.

Also you'll have Javascript on you. But knowing Tk helps you write better there.
The HTML5 canvas isn't too difficult if you know the Tk canvas, and text
widgets also go over easily. (There are libraries for the various kinds of menus
and buttons; they have simple enough models that porting that sort of code is
no big deal in my experience.)

> There have been browser plugins that implemented Tcl/Tk, but I don't know if
> any of that is still available. And they might still require downloading and
> installing a browser plugin.

Not recommended these days. It's not been supported in a *long* time.

Donal.

Ri Ho

unread,
Dec 2, 2020, 4:57:31 PM12/2/20
to

Ri Ho

unread,
Dec 2, 2020, 5:06:09 PM12/2/20
to
On Friday, November 27, 2020 at 8:57:41 PM UTC-7, Robert Heller wrote:
As usual, Mr Heller is right on with his last consideration. Our business partner has 40 vms on Azure which contain our tcl speech rec application. Their clients, client systems simply rdp and, as they say in Russia, voila! Note: it is possible for the same VM to be shared by more than one user (not easy, but possible), and of the vms to mutually share files (also, not easy). BTW: compared to AWS, nothing on Azure was accomplished easily. The reason why 40, instead of 1 shared - speech rec.

PS: for what it is worth, one of my goals is to 'give back' to this site the speech rec code in commercial use - not that any one has asked for it; but it is the only way I know how to materially thank (possibly) those who have helped me, or to pay-it-forward.

Keith Nash

unread,
Dec 7, 2020, 1:52:59 PM12/7/20
to
Robert Heller wrote:

> In any case, it is NOT going to be a Tcl/Tk application. ALL of the "Tk"
> code will have to be completely *replaced* with served HTML[5] (including
> Style Sheets and JavaScript, etc.). This might not be a trivial task.

<snip>

unless ...

> The only other option would be a virtual machine that implements a remote
> desktop -- you could install your program there and the users would fire
> up a
> web based (?) remote desktop. I *think* this might be possible, but don't
> really know.

Amazingly, CloudTk does this and runs the virtual desktop client in
Javascript in the browser.

Christian Gollwitzer mentioned it above:
http://cloudtk.tcl.tk/
https://wiki.tcl-lang.org/page/CloudTk

The demos on the Wiki are impressive. CloudTk is simple to install, with
just a starkit and a standard basekit. I would imagine that the server load
is quite high, because the server sustains a virtual desktop for each
client; but I have not tested this.

Keith.
Message has been deleted

Ri Ho

unread,
Dec 8, 2020, 10:09:48 PM12/8/20
to
On what system in the "web" environment you envision, do you want your tcl program to execute?

Bill Poser

unread,
Dec 8, 2020, 10:21:27 PM12/8/20
to
I don't actually care where the Tcl code executes. The desideratum is that the user be able to execute the program by going to a web site, without the need to have anything special (e.g. Tcl/Tk, browser plugin, starkit) installed on his or her local system. The program is educational, and the request comes from a school administrator whose school district locks down the machines students use so that the cannot download or install software. She would prefer to avoid getting the IT staff to install the program on the students' machines. So I would expect the Tcl code to execute on the server, but if there were a way to have it execute in the browser on the client without installing a special plugin, that would be fine.

Ri Ho

unread,
Dec 9, 2020, 1:52:40 PM12/9/20
to
On Tuesday, December 8, 2020 at 8:21:27 PM UTC-7, billp...@gmail.com wrote:
> I don't actually care where the Tcl code executes. The desideratum is that the user be able to execute the program by going to a web site, without the need to have anything special (e.g. Tcl/Tk, browser plugin, starkit) installed on his or her local system. The program is educational, and the request comes from a school administrator whose school district locks down the machines students use so that the cannot download or install software. She would prefer to avoid getting the IT staff to install the program on the students' machines. So I would expect the Tcl code to execute on the server, but if there were a way to have it execute in the browser on the client without installing a special plugin, that would be fine.

You state "locked down". Does that include limiting the 'web' sites one can access? Seems the choices you have comprise the use of a web site that provides for a tcl\tk web service, or application-resident, virtual desktops (as in Azure, vdp) - probably the easiest and most straightforward solution. Lots of youtube examples.

Rich

unread,
Dec 9, 2020, 2:51:21 PM12/9/20
to
Bill Poser <billp...@gmail.com> wrote:
> I don't actually care where the Tcl code executes. The desideratum
> is that the user be able to execute the program by going to a web
> site, without the need to have anything special (e.g. Tcl/Tk,
> browser plugin, starkit) installed on his or her local system.

This severely limits your options.

> The program is educational, and the request comes from a school
> administrator whose school district locks down the machines students
> use so that the cannot download or install software.

While the "lockdown" itself may have as many holes as a slice of
swiss-cheese, violating the "lockdown rule" by utilizing one of the
holes is likely to get the students (and/or you) in more hot water than
you wish to be in, so this further limits your options.

> She would prefer to avoid getting the IT staff to install the program
> on the students' machines.

Ok, last possible option cut off. Is there any chance the student
computers ship with a Tcl interpreter installed as part of the OS? If
no, then yup, you are quite limited.

> So I would expect the Tcl code to execute on the server,

Given what you've told us, this looks to be your only option without
creating a "rules violation" situation.

> but if there were a way to have it execute in the browser on the
> client without installing a special plugin, that would be fine.

Had the browser world taken a right turn circa 1993-1994 or so instead
of the left turn they did take, then we'd all have browsers with
embedded Tcl interpreters instead of embedded Javascript interpreters.
But, alas, Sun did not pick Tcl when the choice of "Tcl or Javascript"
for embedding in the browser came up way back then, and here we are
with JS in the browser instead of Tcl.

There is a JS implemention of a Tcl interpreter
(https://wiki.tcl-lang.org/page/Tcl+in+Javascript) which might be worth
your time to see if it is complete enough (or if you could reduce your
program down to its limits) to be useful. This would let (if it works)
Tcl code run in the browser (because as far as the browser is
concerned, it is just running a big pile of JS).

But if that does not work, and you need to run the Tcl code server
side, you'll either need to use some kind of remote desktop (so Tk's
windows can be seen by the students) of you'll need to rewrite your
code to talk "HTML" to a browser.
0 new messages