[This page is large and jumbled enough to be a good candidate for refactorization.]
http://www.apple.com/macosx/ is the latest operating system from Apple, which has BSD Unix (approximately) as its underlying core, and a very nice GUI on top of it, known informally as "Aqua". Apple itself seems to be consistent in punctuating the label as "Mac OS X".
ON Mac OS X Tk can be built in three versions; Cocoa (current Apple API), Carbon (deprecated Apple API), and X11. Carbon and Cocoa versions runs natively on Mac OS X, using an Aqua look and feel, which is the focus of this page. The X11 version has a more plain interface, requires the installation of some X11 server, but has better performance than the other two.
OS X Tk is - as of 2012 - in a poor state. Apple's legacy API, Carbon is being deprecated, but it's replacement, Tk Cocoa, has many non-trivial bugs, especially concerning the event loop, and it is largely unsuitable for complicated Tk projects. Moreover, these bugs have proved hard to fix, and there is currently no prospect of them being resolved.
The rest of this page is somewhat outdated.
http://tktoolkit.cvs.sourceforge.net/viewvc/*checkout*/tktoolkit/tk/macosx/README is the URL to the tk/macosx/README file, which was, according to Daniel Steffen, at some point "probably the most complete reference" for OS X specific info/features of Tcl and TkAqua.
Daniel Steffen has a very extensive Batteries Included release available: TclTkAquaBI (superset of ActiveTcl on other platforms). Alphatk used to be bundled with Tcl, Tk, but now embeds them.
ActiveState supports Mac OS X in their ActiveTcl distribution since at least 8.4.13 (see [L1 ]).
Wish comes as an application (Wish.app) and two frameworks: Tcl.framework, Tk.framework. These must be installed in /Library/Frameworks or ~/Library/Frameworks.
There is also a binary distribution "Wish And Go : TclTk for Mac OS X 10.2 Jaguar". This provides a Wish Shell with the Tcl and Tk frameworks and a number of popular extensions all embedded within itself. This stand-alone application is easy-to-install and use, but also provides a good foundation for Building Stand-Alone Tcl/Tk Applications under Mac OS X. It is available from http://simulistics.com/tcltk/ "Wish And Go" is intended particularly for users of Mac OS X 10.2 Jaguar, but also runs on 10.3 Panther. Users of 10.3 Panther will however probably be better served by Daniel Steffen's excellent TclTkAquaBI.
As of October 2002, Tcl is very mature on Mac OS X, but the Aqua-Tk release is less mature than the releases on other platforms (this is still true in January 2004). This means it still contains some bugs which everyone is encouraged to report/fix. As problems are fixed, this page will be updated accordingly. Please note that the tools required to build TkAqua are free from Apple and that it is very easy to build. It is also pretty easy to get the most recent sources from cvs, so you can get all the latest fixes quickly and easily, yourself:
See Steps to build Tcl/Tk 8.4.0 on MacOS X.
IssuesPatches outstanding:
Approximate list of bugs:
Issues fixed in cvs (but which may not be in a distributed binary release).
Outstanding Bugs/Issues as of last change to this page (also see long list of bugs against tktoolkit project at sourceforge):
Issues to be aware of, which may or may not be bugs:
As ever, the source code is available, so everyone is welcome to contribute.
There are some other issues I'm personally having trouble verbalizing (perhaps because I haven't yet investigated them much). For instance, Bryan Oakley's combobox doesn't behave quite the same with respect to keyboard traversal. And there seems to be some issues with packing and/or gridding, but I'm not sure what that is. I see it when I run tkdiff[*] on the mac -- some buttons don't seem to expand properly (ie: checkbuttons that look just great on windows and unix appear too short, which causes the text to wrap and the buttons to be illegible). Maybe this goes back to checkbuttons wanting to wrap rather than take as much horizontal space as possible, but I haven't yet been able to duplicate this easily.
Vince adds: I think this is a bug in which the 'winfo reqwidth' of a checkbutton returns the reqwidth of the text, but doesn't add on the width of the checkbox bit. Does that make sense?
Tkdiff also shows another anomolie I haven't yet tracked down. In its default mode, buttons in the toolbar appear with the text behind the image. The code was originally constructed to assume if you turn images on, the text gets turned off. It could be a bug in tkdiff, but the bottom line is that the mac version is different than on unix and windows.
Vince It shouldn't show both unless you have '-compound', and shouldn't put them on top of each other unless there is '-compound center', so I imagine this is a bug.
[*] the version of tkdiff available from accurev has a bug which prevents it from being run on 8.4, but it's an easy fix. There are a couple places that do "-pad 4" when it should be "-padx 4".
Old problems which have been fixed and appear in a binary release (since July 9th):
28sep02 jcw - Wish can be opened with the "open" command from the command line, but the only way to pass it cmdline-args seems to be to type:
<path_to_Wish.app_dir>/Contents/MacOS/Wish\ Shell arg1 arg2 ...
Also note that a script cannot yet be dropped on Wish to launch it.
8feb03 UKo - but now the 8.4.1 wish can be choosen as starting application for files with tcl-extension
03oct02 - jcw - Another tip from Jim Ingham: if a file is called "blah.command" (say a shell script), then double-clicking it brings up a Terminal window and runs the command in it (at least on 10.2). This does not seem to work when it's a symlink, so better make a copy (or a hard link, I s'pose).
3mar03 - Daniel Steffen - My Launcher [L3 ] utility helps with this (included with TclTkAquaBI or available separately).
18dec02 - Benny Riefenstahl - The 'problem' with the env array is generic to Mac OS X/Aqua. On all Unixes the environment variables are set in shell scripts like ~/.profile, ~/.cshrc or similar. On Aqua the Finder is the login shell, it inherits its environment from the loginwindow application and that can be configured in ~/.MacOSX/environment.plist, see Apple Technote at [L4 ]. Of course, if it is for Tcl only, you can just put additions to the environment variables into ~/.tclshrc.
A recent question on comp.lang.tcl was asking how one sets up Tcl/Tk Aqua on Mac OS X so that a Tcl/Tk script could be double clicked and launch appropriately.
08feb03 UKo The current 8.4.1 Wish is able to respond to the "open" Apple Event and can thus be choosen as application for opening files with the tcl-extension. For older versions (and the last tclkit that runs on non-Jaguar) one can make a applescript like this to start a specific tcl-script or startkit -- here my applescript for starting the local wikit copy:
do shell script "tclkit ~/bin/wikit.kit ~/bin/wikit.tkd"
(be sure to use the POSIX pathnames!)
And here a script that starts a tclkit for every file that is dropped on the script:
on open names repeat with kit in names set command to "tclkit " & (POSIX path of kit as string) & "" -- ignoring application responses do shell script command -- end ignoring end repeat return end open
save this from the applescript editor as program and the you can choose it as open application for any starkit or just drag'n'drop the kit onto the script -- voila.
TODO unfortunately the applescript and the tclkit will both be open -- I don't know how tho make the applescript finish and the tclkit keep on running. (as far as I understand this should be done with the "ignoring" statement -- but it doesn't work for me)
3mar03 - Daniel Steffen - It's probably easier to use my Launcher [L5 ] utility for this (included with TclTkAquaBI or available separately).
Apparently it's important for those working with MacOS X to know about fink, which provides the user the ability to keep installed packages up to date.
No - it's not important to know about fink - the standard MacOSX developer tools are quite sufficient. However, if you want to have a "Debian Linux-like" environment under MacOSX then fink will be of interest. I had fink installed but removed it ... it's fine in what it does but I prefer to work with the Apple tools as far as I can - stevel Feb 9, 2003
There is also Darwinports [L6 ], which is an alternative package manager. Note that this is actually Tcl-based. ;-) BR
X11 is included in the Mac OS X installation disks since 10.3 as an optional package. BR
2003Sep18: On the Mactcl mailing list, Jim Ingham and Kevan Hashemi were discussing what was needed when writing a dynamically loadable extension for Mac OS X. Kevan discovered that:
gcc -c ${INCL} lwdaq.c -o lwdaq.o \ -I/library/frameworks/tk.framework/headers \ -I/library/frameworks/tcl.framework/headers gcc -dynamiclib -o Lwdaq.dylib -framework Tcl -framework Tk lwdaq.o
for his C code resulted in code that is loadable.
2003 Oct 28: On the Mactcl mailing list, Kevan Hashemi and Daniel Steffen answer the question What do I need to do to get a development environment on a Mac OS X machine?
Jason Tang Macs with a Panther install CD/DVD instead must use that disc to run the supplementary applications installer. From there install development tools. Now go to /Applications/Utilities/Installer and run the development tools installer.
DAS goes on to say:
for TEA based extensions, the following configure invocation should do the trick:
./configure \ --prefix=/usr/local --libdir=/Library/Tcl \ --with-tcl=/Library/Frameworks/Tcl.framework \ --with-tclinclude=/Library/Frameworks/Tcl.framework/Headers \ --with-tk=/Library/Frameworks/Tk.framework \ --with-tkinclude=/Library/Frameworks/Tk.framework/Headers \ --enable-threads
You should probably link with stub libraries like on other unix platforms:
gcc -dynamiclib -o yourdylib.dylib yourcommands.o \ -L /Library/Frameworks/Tcl.framework/ -ltclstub8.4 \ -L /Library/Frameworks/Tk.framework -ltkstub8.4
You can build tcl & tk with X11 yourself in the standard unix manner and install into e.g. /usr/local and not bother with the framework based TkAqua.
You'll need X11 & X11SDK from Apple:
http://www.apple.com/macosx/features/x11/download/
Others working with Mac OS X include William Duquette, Jeffrey Hobbs, Cameron Laird, Steve Landers, Bryan Oakley, and Jean-Claude Wippler.
LES on Feb 13, 2004: I was wondering how different MacOS X and Darwin are. I know Tcl/Tk run on both, but is it the same Tcl/Tk or are different ports required for each one?
MKS on Monday, 31 May 2004: Thanks to the help of Benjamin Riefenstahl, I was able to put together a means of having Aqua and X11 installations of Tcl/Tk coexist on the same machine, sharing packages where possible. I compiled the 'unix' codebase and installed it in /usr/local with:
cd $tclsource/unix ./configure --prefix=/usr/loca/ --enable-threads && make && make install cd $tksource/unix !-2
Then installed the "Batteries Included" binary release of the Aqua version.
To make the two versions share packages, I added the following to my ~/.tclshrc:
proc auto_path_handler {} { set ::auto_path_x11 [list /usr/local/lib/tcl8.4 /usr/local/lib] set ::tcl_pkgPath_x11 [list /usr/local/lib] set ::auto_path_aqua [list \ /Library/Frameworks/Tcl.framework/Versions/8.4/Resources/Scripts \ /Library/Frameworks/Tcl.framework/Versions/8.4/Resources \ /usr/lib ~/Library/Tcl /Library/Tcl /Network/Library/Tcl \ /System/Library/Tcl ~/Library/Frameworks /Library/Frameworks \ /Network/Library/Frameworks /System/Library/Frameworks] set ::tcl_pkgPath_aqua [list \ /Library/Frameworks/Tcl.framework/Versions/8.4/Resources/Scripts \ ~/Library/Tcl /Library/Tcl /Network/Library/Tcl /System/Library/Tcl \ ~/Library/Frameworks /Library/Frameworks /Network/Library/Frameworks \ /System/Library/Frameworks] # if the path to the executable contains /local, then it is the X11 # installation, otherwise it is the Aqua installation: if {(([regexp {/local} $::argv0]) || ([regexp {/local} [info nameofexecutable]]))} { set ::auto_path [concat $::auto_path_x11 $::auto_path_aqua] set ::tcl_pkgPath [concat $::tcl_pkgPath_x11 $::tcl_pkgPath_aqua] } else { set ::auto_path [concat $::auto_path_aqua $::auto_path_x11] set ::tcl_pkgPath [concat $::tcl_pkgPath_aqua $::tcl_pkgPath_x11] } return "" } auto_path_handler
These directories are specific to my installation. The best way to determine what yours should be is to start up both tclsh executables and copy out the values given for auto_path and tcl_pkgPath.
This has the effect of allowing package inclusion to search the appropriate location first for either given release, based on which binary is run.
Note X11 and Aqua CANNOT share Graphical packages (though the tclsh that ships with Aqua can load the X11 Tk, and thereafter use X11). In the event that an Aqua binary tries to require a package that is only present in the X11 tree (or vice versa) bad things may happen.
Tk-based applications can look quite good under Aqua. Kevin Walzer gives examples [L7 ].
RLH 2006-10-08: Where does ActiveTcl puts it libraries and stuff? Where would I put my own package to have it picked up by tclsh?
In May 2008, Kevin Walzer lists [L8 ] the principal actors involved in Tcl/Tk for Mac OS.