Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problems with Tk and Mac OS X

252 views
Skip to first unread message

James Regovich

unread,
Mar 25, 2003, 10:03:37 PM3/25/03
to
Hi!

I am trying to get a Tk script to work under Mac OS, but it doesn't work
properly if I run it using #!/usr/bin/wish as the first line of the script.

It does work work if I do wish <script>.

Has anyone seen this before?

Jim Regovich
Concord Communications
jreg...@concord.com

Philipp Roessler

unread,
Mar 26, 2003, 7:46:44 AM3/26/03
to
In article <3e81184c$1...@news.concord.com>, James Regovich
<jreg...@concord.com> wrote:

> I am trying to get a Tk script to work under Mac OS, but it doesn't work
> properly if I run it using #!/usr/bin/wish as the first line of the script.

How do you try to invoke it? I assume you've made sure that 'wish' resides
in /usr/bin. So what is the error message?

Phil

James Regovich

unread,
Mar 26, 2003, 8:43:39 AM3/26/03
to


I run it as an executable shell script, when I invoke it I get error
messages first about invalid arguements to the package command. The
error messages are all relating to issuing Tcl/Tk commands in a normal
shell, so the shell for some reason is not picking up the #!/usr/bin/wish:

./blah.tcl
package: unrecognized parameter: mclistbox
Usage: package [-f] rootDirectory infoFile [-d destinationDirectory] [-r
resourceDirectory] [-ignoreDSStore]
* rootDirectory - a directory containing the files to be added to the
package
* infoFile - contains the package specific information and flags
* destinationDirectory - the location where the package will be built
* resourceDirectory - a directory containing any necessary scripts or
documents
Missing }.
proc: Command not found.
wm: Command not found.
destroy: Command not found.
frame: Command not found.
scrollbar: Command not found.
scrollbar: Command not found.
mclistbox: Command not found.
.listbox: Command not found.
.listbox: Command not found.
.listbox: Command not found.
.listbox: Command not found.
ButtonPress-1: No such file or directory.
ButtonPress-1: No such file or directory.
grid: Command not found.
grid: Command not found.
grid: Command not found.
grid: Command not found.
grid: Command not found.
grid: Command not found.
grid: Command not found.
pack: Command not found.
set: Variable name must begin with a letter.

Kevin Kenny

unread,
Mar 26, 2003, 9:23:02 AM3/26/03
to
James Regovich wrote:

> >>I am trying to get a Tk script to work under Mac OS, but it doesn't work
> >>properly if I run it using #!/usr/bin/wish as the first line of the script.

There are so many different problems that can have those symptoms
that I gave up on that technique a long time ago. What I do now is:

#! /bin/sh
# hideous kludge: the next line is a comment in tcl. \
exec /path/to/wish "$0" ${1+"$@"}

# tcl code here.

--
73 de ke9tv/2, Kevin

James Regovich

unread,
Mar 26, 2003, 3:42:38 PM3/26/03
to
Here is what I found, thanks to an email from a friendly poster:

/usr/bin/wish is a symlink to wish8.4 which is a shell script that calls
the real wish. Since the shell script doesn't do things properly at
startup, I relinked /usr/bin/wish to the real wish and all is good.

Lincoln Ramsay

unread,
Mar 26, 2003, 4:46:13 PM3/26/03
to
At around 27/03/2003 1:23am, Kevin Kenny declared:

> James Regovich wrote:
>>>>I am trying to get a Tk script to work under Mac OS, but it doesn't work
>>>>properly if I run it using #!/usr/bin/wish as the first line of the script.

If you're using the aqua binaries, the wish binary is
/Applications/Wish.app/Contents/MacOS/Wish. If you symlink this to
/usr/bin/wish, scripts won't launch correctly. I'm not sure why.

A workaround is to create a shell script that calls the binary...

eg.
$ cat /usr/bin/wish
#!/bin/sh
exec /Applications/Wish.app/Contents/MacOS/Wish "$@"

--
Send email to ramsayl at dodo dot com dot au \|/
. (- -)
+----------------------------------------------ooO--(_)--Ooo--+
| There is no emotion, there is peace. There is no ignorance, |
| there is knowledge. There is no passion, there is serenity. |
| There is no death, there is the force. -- Jedi Code |
+-------------------------------------------------------------+

Daniel A. Steffen

unread,
Mar 27, 2003, 6:40:21 AM3/27/03
to
In article <3e82102d$1...@news.concord.com>, James Regovich
<jreg...@concord.com> wrote:

> /usr/bin/wish is a symlink to wish8.4 which is a shell script that calls
> the real wish. Since the shell script doesn't do things properly at
> startup, I relinked /usr/bin/wish to the real wish and all is good.

what exactly doesn't the shell script do properly?

it certainly works for me with popular tk scripts I tried such as tkman
& tkdiff (although they probably all use the exec wish technique kenny
mentioned)

you should definitely report this as a bug on SF so that we can fix
it...

Cheers,

Daniel

--
** Daniel A. Steffen ** "And now to something completely
** Dept. of Mathematics ** different" Monty Python
** Macquarie University ** <mailto:ste...@maths.mq.edu.au>
** NSW 2109 Australia ** <http://www.maths.mq.edu.au/~steffen/>

Michael A. Cleverly

unread,
Apr 1, 2003, 12:48:04 AM4/1/03
to
On Thu, 27 Mar 2003, Lincoln Ramsay wrote:

> At around 27/03/2003 1:23am, Kevin Kenny declared:
> > James Regovich wrote:
> >>>>I am trying to get a Tk script to work under Mac OS, but it doesn't work
> >>>>properly if I run it using #!/usr/bin/wish as the first line of the script.
>
> If you're using the aqua binaries, the wish binary is
> /Applications/Wish.app/Contents/MacOS/Wish. If you symlink this to
> /usr/bin/wish, scripts won't launch correctly. I'm not sure why.
>
> A workaround is to create a shell script that calls the binary...
>
> eg.
> $ cat /usr/bin/wish
> #!/bin/sh
> exec /Applications/Wish.app/Contents/MacOS/Wish "$@"

I tried the above and still can't get scripts to launch (other than
invoking them from a shell) on my wife's iMac.

Here's what I've got in /usr/bin/wish:

#!/bin/sh
exec "/Applications/Utilities/Wish Shell.app/Contents/MacOS/Wish Shell" "$@"

And a little test script in ~/Desktop/hello-world.tcl:

#!/bin/sh
# -*- tcl -*- \
exec wish "$0" ${1+"$@"}

button .hello -text "Hello!" -command bell
button .world -text "Goodbye" -command exit
pack .hello .world

If I open a shell and type: Desktop/hello-world.tcl everything works. If
I double click on the hello-world.tcl file on the Desktop wish starts up,
but my script isn't sourced, and I'm left with a blank main window (.) and
the tk console.

Suggestions?

Michael

Daniel A. Steffen

unread,
Apr 1, 2003, 2:08:37 AM4/1/03
to
Michael,

In article
<Pine.LNX.4.44.03033...@gibraltar.cleverly.com>,


Michael A. Cleverly <mic...@cleverly.com> wrote:

> I tried the above and still can't get scripts to launch (other than
> invoking them from a shell) on my wife's iMac.
>
> Here's what I've got in /usr/bin/wish:
>
> #!/bin/sh
> exec "/Applications/Utilities/Wish Shell.app/Contents/MacOS/Wish Shell" "$@"
>
> And a little test script in ~/Desktop/hello-world.tcl:
>
> #!/bin/sh
> # -*- tcl -*- \
> exec wish "$0" ${1+"$@"}
>
> button .hello -text "Hello!" -command bell
> button .world -text "Goodbye" -command exit
> pack .hello .world
>
> If I open a shell and type: Desktop/hello-world.tcl everything works. If
> I double click on the hello-world.tcl file on the Desktop wish starts up,
> but my script isn't sourced, and I'm left with a blank main window (.) and
> the tk console.
>
> Suggestions?
>

this is a FAQ, Wish behaves like this by design (of Mac OS X)...
See the tcl-mac list archives for more details and many existing
answers to this question.

Essentially, do get what you want, install my Launcher utility
http://www.maths.mq.edu.au/~steffen/tcltk/Launcher/
(included with TclTkAquaBI 8.4.2.0)
and associate your script with the Launcher.app in the Finder info
window. Then, double-clicking will launch a new instance of Wish and
pass it your file as an argument.

0 new messages