From deleeuw at stat.ucla.edu  Sat Feb 21 23:16:08 2004
From: deleeuw at stat.ucla.edu (Jan de Leeuw)
Date: Sat Feb 21 23:16:19 2004
Subject: [Rd] GUI from Terminal.app
Message-ID: <8C6AE987-64BB-11D8-B592-000A95A67E82@stat.ucla.edu>

If you start R from the terminal and then do non-X11 graphics, you
get SetFrontProcess errors. For instance, I have a version of R
configured without x11 and with the Aqua version of tcl/tk. If
I start this, load tcltk, and do tkStartGUI() I cannot bring the window
to the front, because clicking it gives SetFrontProcess errors.

There is, however, a simple way to fix this. Make a copy of R.bin,
call it RGUI, then say

/Developer/Tools/Rez -t APPL Carbon.r -o RGUI

and change the name of the R binary in the R startup script from R.bin
to RGUI. Then this R will give a tkStartGUI window that you
can interact with. The same is true for the tk demos, which
now have nice aqua windows you can interact with.

Also, starting quartz() and interacting with the quartz device works  
fine,
and demos such as tkdensity now display two nicely interacting
aqua windows. Also, you get a working version of Rcmdr in this way.
Thus you have a version of RAqua which does not use the RAqua
GUI but only the terminal. And we have a seemingly reliable way to
use Aqua tcl/tk (and get rid of all of X11). It does not cost anything  
to add the
Rez command above to the Makefile, and the benefits are huge. There
does not seem to be a need to warn if quartz() is started from the
terminal.

Remains the fact that I have been looking for this solution for two  
years
and it turns out to be this simple. Must be pretty well hidden. Observe
the Rez command gives RGUI a resource fork and metafile info, also
observe this would not work with Cocoa.

===
Jan de Leeuw; Professor and Chair, UCLA Department of Statistics;
Editor: Journal of Multivariate Analysis, Journal of Statistical  
Software
US mail: 8130 Math Sciences Bldg, Box 951554, Los Angeles, CA 90095-1554
phone (310)-825-9550;  fax (310)-206-5658;  email: deleeuw@stat.ucla.edu
homepage: http://gifi.stat.ucla.edu
   
------------------------------------------------------------------------ 
-------------------------
           No matter where you go, there you are. --- Buckaroo Banzai
                    http://gifi.stat.ucla.edu/sounds/nomatter.au


[Rd] GUI from Terminal.app
Jan de Leeuw