Updated 2013-03-05 02:22:10 by pooryorick

Summary  edit

information about the use of Tcl and Tk on MacOs and MacOS X operating systems on Apple's Macintosh computers.

Here is some more recent info, concerning OS X:

Distributions  edit

MacOS X comes with Tcl installed! With Tiger you also get a good selection of basic extensions, a subset of TclTkAquaBI. The state-of-the-art distribution of TclTk for OS X is Daniel Steffen's BI distro TclTkAquaBI. It's a breeze to install, and it comes with lots of useful extensions. ActiveState also distributes ActiveTcl for OS X.

Mailing list  edit

There is a mailing list dedicated to Tcl on the Mac: https://lists.sourceforge.net/lists/listinfo/tcl-mac

Alpha  edit

Alpha, the powerful text editor for the Mac, has gone X! The beta version (requires OSX 10.2) is available from http://www.maths.mq.edu.au/~steffen/Alpha/AlphaX/ . Most of Alpha's functionality is written in Tcl — so it is easy to tweek, extend, and script, making it do whatever you want and whatever can be done in Tcl!

The classic Alpha was already an amazing text editor — AlphaX is just much more powerful because it has easy access to the unix underpinings of OSX. Everyone interested in Tcl on the Mac should give Alpha a try. (Needless to say: Alpha has a very fancy Tcl mode for editing Tcl scripts...) Alphatk is also available on MacOS X.

More Unix Software for Your Mac  edit

The package manager Fink is one of the easiest ways of installing unix software on your Mac. But you should also be aware of the developing DarwinPorts project (itself written in Tcl!).

Q: How do I install Tcl related packages (extensions, etc.) on the Macintosh?

A: Check first if the extension isn't already in the TclTkAquaBI batteries included distribution by Daniel Steffen or ActiveTcl.

Q: On what versions of Mac hardware and software does Tcl run?

A: All Macs should run Tcl, the limit is the version of the OS. Tcl has been ported to the Classic MacOS up to version 8.4, later versions will require OS X to run. Also, some popular extensions were not ported to Classic MacOS.

Q: How do I run Tcl/Tk on the Macintosh?

A: There are several alternatives. The source code for Tcl and Tk can be found at their SourceForge projects (see the Tcl Core Team page). This option requires you to know about Compiling Tcl on a Mac.

Another option would be to download the binary distributions.

Yet another option would be to download a Tclkit for the Macintosh - however, I don't know whether this is the latest Tcl and Tk or not.

Q: Can I run popular Tcl and Tk applications on the Mac?

A: Probably not without some modifications. Often writers of applications do so without realizing some of the cross platform issues required to be taken into consideration. What should I be sure to do so my Tcl based programs run cross platform?

MacTcl mailing list: http://lists.sourceforge.net/lists/listinfo/tcl-mac

One interesting project for MacOS X is Fink.

mailto:[email protected] wrote in comp.lang.tcl :

Here are a couple of AppleScripts that may help speed up the edit/run cycle ( at least for small scripts...). My intent is to quickly send a script to "Wish" from BBEdit or Alpha. The following scripts will send the contents of the front window of BBEdit or Alpha to the Application wish.

For BBEdit ( I am using 6.0.1...) place the following script into the Scripts folder in BBEdit support. I named the script: "Send Script to Wish" and saved it as an application.
 --Get the contents of the front BBEdit Window

 tell application "BBEdit 6.0"
        set theFile to contents of text window 1
 end tell

 -- Give the contents to Wish

 tell application "Wish"
        activate
        do script theFile
 end tell

For Alpha I had to install OSA Menu ( a nifty tool) and installed the following script in the Folder Alpha Scripts in the Scripts folder of the System Folder. Again I saved the script as an application named "Send Script to Wish"
tell application "Alpha"
       set theFile to DoScript "getText [minPos] [maxPos]"
end tell

 -- now send the script to wish...
tell application "Wish"
       activate
       set myResult to do script theFile
end tell

Scripts without errors work fine, seems like I should be able to do a bit more with "bad" scripts...

The Tcl menu in Alpha contains a bunch of commands which can do all this sort of thing for you. Also if you activate the Remote Tcl Shell package, you can use Alpha as a command-line shell (i.e. a console) for Wish.

The items in the Tcl menu are of two types:

'evaluate remotely' -- if this flag is set, you can send the contents of the current window to Wish by simply selecting all (cmd-A) followed by evaluate (cmd-L). Similarly with any code-snippet.

Also you can 'execute command', and 'execute file in remote shell'. (note that this section on the Tcl menu in Alpha also applies to the Tcl menu in Alphatk should also work on Windows, Unix).

jkock 2003-06: Most of the information below the next dividing line seems to refer to Mac OS9 and is therefore rather outdated.

  • How do I mark MacOS Tcl scripts so that they run when clicked?

LV: A recent posting on clt by Melissa Schrumpf goes into a lot of detail about this topic - read over it!
Newsgroups: comp.lang.tcl
Subject: Re: Using Tcl on Macintosh, but !!!!
Date: Thu, 03 Jan 2002 23:31:30 -0500
Message-ID: <reverse-comDOTyahooATm_schrumpf-611B36.23312903012002@news.newsguy.com>
References: <[email protected]>

In article <[email protected]>,
"ahcene" <[email protected]> wrote:

> I use Tcl on macintosh since a few months.
> 
> I have wrote with PC a file in text mode and saved it "myfile.tcl". I can
> execute it directly by do double click on its icon.
> 
> Using the same file (myfile.tcl) on macintosh (imac)using , I can execute it
> if I open Wish and use Source Command (File Menu).
> But, I can not execute it directly (i.e. to do double click on its icon).
> 
> So, I want help to execute my file (myfile.tcl) directly by do click on its
> icon.

MKS:

Windows tracks file extensions in the registry, and for each extension, may define a default file opener command.

MacOS classic assigns each file a type and creator 4-character code. each application has a tpye of APPL, and, ideally, a unique creator code. each file gets a creator code. The OS then opens a file by looking up the creator code, and opening the file with the application having the same creator code.

The MacOS way has its benefits. For example, Photoshop or Word are bulky and bloated. So, files that are require their features may have a matching creator code, while normal text files may open in SimpleText.

It also gives you the ability to move applications around your hard drive without breaking the double-click-to-open file feature, as may happen win Windows.

Unfortunately, the down side to this is that two applications having the same creator on one machine will result in an uncertain outcome. Only one of the applications will ever open files of that type.

The 8.3.x MacOS distro comes with a slew of creator==WIsH type applications. Thus, which one becomes the default opening program for files of that type is uncertain.

For MacOS classic, look for the application "Drag & Drop Tclets." The MacOS way of doing this is to cram the text of the tcl script into a resource of a copy of the Wish binary. Essentially, if you use a portable Wish stub, this creates fully-portable applications the way FreeWrap does for Windows.

Unfortunately, this is rather annoying for development, and causes disk bloat.

So hack it. Make a copy of the "Drag & Drop Tclets" application and rename it something, say, My_Wish. Next, open My_Wish in a resource editor (e.g. ResEdit). Edit the "text" resource, there should be one item, with the name of "tclshrc". Open this item, delete the script text, and replace it with the following:
# this is required:
proc tkOpenDocument {args} {
    foreach varn {tkPriv.:0 tcl_version argv argv0 tcl_interactive\
        tcl_nonwordchars tcl_traceCompile tk_library tk_version\
        errorCode auto_path tk_strictMotif errorInfo tcl_wordchars\
        tkPriv env tcl_pkgPath tcl_rcRsrcName auto_noexec\
        tcl_patchLevel argc tk_patchLevel tcl_traceExec tcl_platform\
        tcl_library} {
            upvar #0 $varn $varn
    }
    foreach fil $args {
        if {[catch {source $fil} res]} {puts stderr $res}
    }
}


# this is optional:
console show

Now save My_Wish. You can now drag & drop tcl script files onto My_Wish and they will automatically run.

But you wanted to be able to double-click. so, change the creator type of My_Wish from "WIsH" to "MyWs", and change the creator of your tcl script file to "MyWs". for My_Wish, uncheck the "Has Been Inited" checkbox -- this will cause the finder to reload its info, and add it to the Desktop Database (analagous to the Windows registry for file extensions).

Now, double-clicking on the tcl script will open the file in My_Wish. Note that some editors will clobber the creator code of your files, so you'll probably just want to avoid the creator code modifications & stick to drag & drop.

Note from mailto:[email protected]

Installing Mac Tcl/Tk 8.3.2 will replace the Tool Command Language folder in the Extensions folder with an alias to a folder in the installation directory. Unfortunately this will probably break older applications (such as SpecTcl 1.1)which is compiled to use a 8.0 library. SpecTcl can be "recovered" by the following procedure.

  1. Drag the Tool Command Language alias out of the system folder.
  2. Run the SpecTcl 1.1 installer, this will create a new TCL folder
  3. Copy the contents of the new TCL folder to the folder pointed to by the alias TCL folder.
  4. Remove the just created TCL folder.
  5. Put the TCL alias back into the Extensions Folder.

SpecTcl should now run...

Daniel Steffen: This problem is fixed in Mac Tcl/Tk installers 8.3.3 and later.

Note from mailto:[email protected]

Visual TCL, a GUI editor written in "Pure TCL" is broken in Mac TCL/Tk 8.3.1-2. An error is thrown when you try to save a file. The problem appears to be caused by the non recognition of the "-filetypes" switch on the "tk_getSaveFile" command. To the best of my knowledge this occurs only one time in the source (all in tcl!) Carefully edit out the occurrence of this option and this particular problem will go away.

Daniel Steffen: This problem is fixed in Mac Tcl/Tk 8.3.3 and later.

See Also  edit

Compiling Tcl on a Mac
[1]
itouchbrowser
a Windows program to manipulate files on an itouch. Home page talks about supporting tcl text files
sdx under macos
macintosh specific tcl commands
macspeech
macgoodies
macbag
macfsbox
how to ensure my windows or macos tk process has a console
steps to build tcl/tk 8.4.0 on macos x
aegizmos extension
applehelp