Re: [R] Off topic: Tcl/Tk outside R.

From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>
Date: Mon, 14 Jul 2008 09:15:29 +0200

Rolf Turner wrote:
>
> I'm trying to learn about the tcltk package and its uses. Floundering
> around a bit ... Have discovered Peter Dalgaard's articles in R-News,
> which should help. Also James Wettenhall's suite of examples look like
> they might be enlightening, even though the indications are that they are
> Windoze oriented.
>
> Be that as it were, I decided to fool around a bit with Tcl/Tk *outside*
> of R to see if I could get the hang of just what Tcl/Tk actually is.
> (As I said I am floundering; I can't seem to get a conceptual grip on
> what it's all about.) I discovered a Tcl/Tk ``Cookbook'' by Sastry
> and Sastry that looked promising. URL:
>
> http://www.dci.clrc.ac.uk/Publications/Cookbook/
>
> Tried the first couple of (ultra-simple) examples and they seemed to
> work.
> (Amazing, for me.)
>
> Then I tried the example on creating an executable file for invoking
> the Tcl/Tk commands. The instructions said to create a file
> ``button.tcl'' with a first line
>
> #!/usr/bin/wish
>
> and succeeding lines
>
> button .b -text "Press Me" -command exit
> pack .b
>
> I did this, did a chmod to make the file executable, and then typed
>
> button.tcl
>
> at the command line prompt. I got the error messages
>
> tcsh: button: Command not found.
> tcsh: pack: Command not found.
>
> So the code at the beginning of the script telling the machine
> to use the ``wi'' shell (rather than tcsh) is being ignored.
> Why?
>
> The Tcl/Tk executables really are in /usr/bin.
>
> If I invoke ``wish'' interactively, and then type in the ``succeeding
> lines''
> interactively the ``Press Me'' button pops up as it should. (And goes
> away
> when I click on it.)
>
> Also if I type ``wish button.tcl'' then it seems to work; i.e. the button
> pops up and goes away when clicked.
>
> Can anyone give me a hint as to why it doesn't work when the the
> executable
> script is invoked directly (from tcsh)? Other than the fact that I'm
> using a Mac :-) .
>
> [Invoking unname -a gives ``Darwin TURNER-ROLF.local 8.11.1 Darwin Kernel
> Version 8.11.1: Wed Oct 10 18:23:28 PDT 2007;
> root:xnu-792.25.20~1/RELEASE_I386 i386 i386''.]
>
> The Tcl/Tk software, from what I can glean, appears to be version 8.4
> (???).
>
> Thanks for any insights.
Odd... That _does_ actually work for me, so I guess the issue is Mac-specific. One thought:
Tcl is like R; a core language where you load packages in order to do any real work and wish is just Tcl with the Tk package preloaded. I.e., the following also works for me

$ cat rolf.wish
#!/usr/bin/tclsh
package require Tk
button .b -text "Press Me" -command exit pack .b

-- 
   O__  ---- Peter Dalgaard             ุster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard_at_biostat.ku.dk)              FAX: (+45) 35327907

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Mon 14 Jul 2008 - 07:21:01 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 14 Jul 2008 - 20:33:47 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive