Invoking the Tcl Plugin

revised 21 May 2006
Google site search

You need the Tcl Plugin to read this page. If this spot  is not green (v2) or cyan (v3)you may want to download the latest Tcl Plugin.

1.1   Arguments with the Tcl Plugin        

Here is the tclet from the previous page again alongside its html code.. This tclet invokes the same file. In theory a tclet only needs to be held on the www once (on a reliable server) to be available to the whole world all the time. This quality is worth reflecting on.

Exercise - write down the pros and cons of the global availability of tclets.

    <param name='myArg' value='itsValue' />
    <param name='src' value='echoparams.tcl' />
    <param name='type' value='application/x-tcl' />
    <param name='pluginspage' value='' />


You can see listed in this tclet the values of the embed_args array. This is the way that the tclet sees the options in the <object/embed> tag.

Notice that "id" and "classid" do not appear in the embed_args array. This keeps the interface the same as for <embed>.

Notice that there is one extra variable in the embed_args array, embed_args(embed_mode) which is set to embed even for Internet Explorer! Tclet code can be run as a freestanding program as well as in a webpage. embed_mode is the way you can tell if Tcl program is being used in a tclet on a webpage.

Within the Tclet the embed_args array contains an element for each parameter passed into the tclet from the html. This means that you can size your tclet based on the embed_args(width) and embed_args(height) values that are given to it by the webpage. The height and width values passed into the tclet can be used there to scale the tclet if you wish or to determine if the tclet needs scrollbars to be displayed properly.

This tclet is an example of the use of the Tk text widget. The area with the text is the text widget area. Thats not includeing the red border which is a frame widget, and not including the scrollbar on the right, which is a scrollbar widget. This area, the text widget, comes with a whole lot of built-in user interactions (bindings) that allow you to modify what appears in the text earea. Notice that you can drag the mouse up or down to scroll the text widget and the scrollbar moves with you just the same way as you scroll a webpage in your browser. Notice also that you can select portions of text: they get a blue background. You can also edit (change) the text which is something you cannot do in an ordinary webpage. These are all builtin behaviours of the Tk text widget.

You need to click inside the plugin frame in order to get focus. Then you can move the scrollbar. The text widget containing the text has text editor functions - select ,insert and delete. Copy and Paste are not available as they access the system clipboard. In fact an attempt to Copy (<Ctrl-Insert>) causes an error.

The Tclet code is shown below. As you can see the Tclet just echoes the embed_args values back. someArg becomes an array element variable known in the Tclet.

frame .f  -borderwidth 10 -relief raised -background #ff0000
pack .f
text .f.t -yscrollcommand { set} -width 60
pack .f.t -side left -fill both -expand true
scrollbar -command {.f.t yview} -orient vertical 
pack -side right -fill y

.f.t insert end "Echo Plugin Parameters"
foreach i [array names embed_args] {
     .f.t insert end "\nembed_args($i) = $embed_args($i)"

# Notes on this Tclet
# the frame .f enclosing the text and scrollbar widgets is given some borderwidth,
# relief and colour so that you can see it clearly.
# the frame height and width dimensions are in pixels 
# while the text height and width are in lines and characters respectively
Prev Next

©2000 - 2006 WEBSCOOL This page last updated 02 Jun 2006. All rights reserved - including copying or distribution of any portion of this document in any form or on any medium without authorisation. For more regarding the copyright.