Instructions For Writing Tclets

[ Sun Home | Tcl Home | Tcl Plugin ]


These instructions should be updated shortly for the new version 2.0 features

Here is a cookbook for how to write your first tclet:

That's IT. You're done. This page should look like what you've created above.

Feedback is appreciated! If you want to send in a comment, just email to sunscript-plugin@sunscript.sun.com. All comments are welcome, and email will be acknowledged if you include a reply-to address.

Safe Tcl and Safe Tk

You can test your Tclet by running it in the wish shell; you don't have to run it inside Netscape. However, when you are running in the Tcl plugin you have a restricted set of Tcl commands for security reasons. The following Tcl commands are not available:

Stand Alone or Plug In?

You can detect if you are running in the plugin by testing for the existing of the embed_args variable. This is an array whose values come from the <embed> tag in the document. For example, $embed_args(src) contains the name of the Tcl script for the applet. You can put whatever NAME=VALUE pairs you want in the <embed> tag. The Plugin looks at SRC, WIDTH, and HEIGHT. Any others are for your own use.

Other Tcl variables defined especially for the plugin are:

nptcl_version
String describing the plugin version such as "1.0"
nptcl_patchLevel
String describing the plugin patch level, such as "1.0"

Window sizing

The plugin turns off geometry propagation for the main window. All it does is:

pack propagate . false

This helps make the window the same size as the HTML width and height specifiers in the <embed> tag. Tclets you write should still work if they depend on the grid geometry manager, but in that case, you'll have to size the window yourself.

grid propagate . false