[ Team LiB ] Previous Section Next Section

Macintosh OS 8/9 and ResEdit

If you want to create a self-contained Tcl/Tk application on Macintosh OS 8 or 9, you must copy the Wish program and add a Macintosh resource named tclshrc that has the start-up Tcl code. The Tcl code can be a single source command that reads your script file. Here are step-by-step instructions to create the resource using ResEdit:

  • First, make a copy of Wish and open the copy in ResEdit.

  • Pull down the Resource menu and select Create New Resource operation to make a new TEXT resource.

  • ResEdit opens a window and you can type in text. Type in a source command that names your script:

    source "Hard Disk:Tcl/Tk 8.3:Applications:MyScript.tcl"
    
  • Set the name of the resource to be tclshrc. You do this through the Get Resource Info dialog under the Resources menu in ResEdit.

This sequence of commands is captured in an application called Drag n Drop Tclets, which comes with the Macintosh Tcl distribution. If you drag a Tcl script onto this icon, it will create a copy of Wish and create the tclshrc text resource that has a source command that will load that script.

If you have a Macintosh development environment, you can build a version of Wish that has additional resources built right in. You add the resources to the applicationInit.r file. If a resource contains Tcl code, you use it like this:

source -rcrc resource

If you don't want to edit resources, you can just use the Wish Source menu to select a script to run.

Macintosh OS X

Mac OS X can run the same Tcl/Tk as Macintosh system 8 or 9. However, the preferred version for Mac OS X is Tcl/Tk Aqua, which uses the native windowing system known as Aqua. There are some differences in the application structure due to the new application framework used when building this variant. Wish checks the Resources/Scripts directory in its application bundle for a file called AppMain.tcl, if found it is used as the startup script and the Scripts folder is added to the auto_path. This is similar in spirit to the tclshrc resource described above. Daniel Steffen deserves a great deal of credit for the Tcl/Tk Aqua port and his continued support of the Macintosh platform. He has put together a great distribution that includes many popular extensions, which you can find on the CD-ROM. You can find out more about Tcl/Tk on Macintosh through these URLs:

http://wiki.tcl.tk/macos/

http://www.maths.mq.edu.au/~steffen/tcltk/

    [ Team LiB ] Previous Section Next Section