www.gibmonks.com

  Previous section   Next section

Practical Programming in Tcl & Tk, Third Edition
By Brent B. Welch

Table of Contents
Chapter 2.  Getting Started


The Macintosh and ResEdit

If you want to create a self-contained Tcl/Tk application on Macintosh, 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.1: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.


      Previous section   Next section
    Top