Already during implementing
incr tcl in javascript there was the decision to use
wtk as the frontend for GUI building.
wtk (WebTk) is a
Tk like implementation of some widgets (frame, entry, button, label, checkbutton and canvas) and a rudimentary implemenation of a grid manager. It is based on the idea to separate the data and administration part of the GUI from the presentation part. The communication between the two parts can be done in different ways:
- Using a direct function call to the wtk client side functions
- Using a client/server solution which is running the client part (the presentation part in javascript) in the browser and the server part (the Tcl part) on the serving machine
The base for the above implementation is a snit class widget, which can create and administrate a widget. It is (from the comment of the implementation of
Mark Roseman): A 'generic' widget object, which handles routines common to all widgets like assigning it an id, keeping track of whether or not it has been created, etc. Purely for convenience, we also include some code here that manages widgets that use -text or -textvariable, though not every widget will do so.
The “mega”widgets like frame, button, entry etc. are built with snit classes, which delegate a lot of functionality to the widget base class. Again a comment from
Mark Roseman from the implementation:
- Stuff for defining different widget types here. Note that all widgets are expected to implement the "_createjs" method. This is called by the generic widget code, and should return a javascript command that can be used to create the widget on the web side of things (i.e. calls routines in wtk.js).
- Widgets that support -text and -textvariable are expected to implement the "_textchangejs" method, which is called by the text handling pieces of the generic widget code, and should return a javascript command that will change the text of the widget on the web side to match the current internal state of the widget here.
- Widgets that receive events from the javascript side are expected to implement the "_event" method, which is passed the widget-specific type of event and any parameters.
Wtk.js is a set of functions building the base of the repesentation/displaying (client side) part.
Communication between the administrative side and the displaying side is done using two global procs:
These classes and procs have been used to implement a running version in
incr tcl in javascript using a few
javascript classes to allow the direct communication with the interpreter written in
javascript.