Advanced Search
Mail us
Home    Manuel    Links    Faq    Submit a tcl/tk Reference    Contact Us

    Some examples tcl/tk codes     Man of Bwidget     Man of blt     mkwidget screenshots     TkOgl     Video Demo real.

  How do I run Tcl/Tk scripts by double-clicking on Windows/Mac?
 For Windows95/NT, the installation should associate `.tcl` to launch
wish.  However, if this is not done properly, you can do it yourself by
going to Explorer->View->Options->File Types and creating a file type to
associate to `.tcl` that has the `open` action as `"C:Program
FilesTclinwish80.exe" "%1"` (or whereever you chose to have wish

You can optionally create an `Edit` action as well.  Don`t choose
`notepad` as that doesn`t understand Unix text files (which just use a
line feed for the end of a line, as opposed to carriage return and line
feed on Windows and just carriage return on the Mac.  I recommend
finding a copy of `emacs`, but `write` will do.

As for the Mac, it`s a little more complicated.  Jim Ingham tells us:

There are two things here.  One is using scripts in `TEXT` resources.
The other is double-clickable apps.

1) `TEXT` resources: Make a named resource of type "TEXT" in the app or
any of its shared libraries, and source it in with the command:

source -rsrc resourceName

2) Double-Clickable Apps: define a proc called `tkOpenDocument`. To get
this to source at startup, you will have to do something like put it in
the Tk `TEXT` resource of the Tk shared library, or some other script
that gets sourced before or during the Tk startup.  In it you can either
do this to make a droplet:

proc tkOpenDocument {args} {
   foreach file $args {
      after idle [list source $file]

The after idle is necessary if you load any other extensions or scripts
in the startup, since the `tkOpenDocument` gets run for the Original
Open Document event gets run in the `Tk_Init` procedure...

Or just source in the code for your application, for instance using the
source -rsrc from 1 above.