[R-gui] Not a bug in Rcmdr, GUI for require(package)?

John Fox jfox at mcmaster.ca
Thu Jul 15 03:17:00 CEST 2004


Dear James,

> -----Original Message-----
> From: r-sig-gui-bounces at stat.math.ethz.ch 
> [mailto:r-sig-gui-bounces at stat.math.ethz.ch] On Behalf Of 
> James Wettenhall
> Sent: Wednesday, July 14, 2004 7:09 PM
> To: John Fox
> Cc: 'Feng, Yang [Ontario]'; r-sig-gui at stat.math.ethz.ch
> Subject: RE: [R-gui] Not a bug in Rcmdr, GUI for require(package)?
> 
> Hi John,
> 
> On Wed, 14 Jul 2004, John Fox wrote:
> > implement it in a cross-platform manner. I don't know how 
> to do that 
> > via tcltk or I'd offer to do it.
> 
> I think I know how to do it via Tcl/Tk, but if using Windows 
> with the GraphApp Rgui running (even in SDI), there are 
> likely to be some annoying focus-stealing problems between 
> GraphApp and Tcl/Tk because of some of the GraphApp widgets 
> that pop-up (e.g. progress bar) when you install a package.
> 

Actually, after thinking about this a bit more, I do see how to do it via
tcltk. Here's a rough version, which seems to interact OK with the progress
bars:

installPackages <- function(){
    top <- tktoplevel()
    tkwm.title(top, "Install Packages")
    names <- CRAN.packages()[,1]
    onOK <- function() {
        packages <- names[as.numeric(tkcurselection(listbox)) + 1]
        install.packages(packages, lib=.libPaths()[1], destdir="c:/temp") 
        tkgrab.release(top)
        tkdestroy(top)
        }
    onCancel <- function(){
        tkgrab.release(top)
        tkdestroy(top)
        }
    frame <- tkframe(top)
    listbox <- tklistbox(frame, height=min(10, length(names)),
        selectmode="extended", background="white", exportselection="FALSE")
    scrollbar <- tkscrollbar(frame, repeatinterval=5, command=function(...)
tkyview(listbox, ...))
    tkconfigure(listbox, yscrollcommand=function(...) tkset(scrollbar, ...))
    for (name in names) tkinsert(listbox, "end", name)
    tkgrid(tklabel(frame, text="Select one or more packages", fg="blue"),
columnspan=2, sticky="w")
    tkgrid(listbox, scrollbar, sticky="nw")
    tkgrid.configure(scrollbar, sticky="wns")
    tkgrid.configure(listbox, sticky="ew") 
    tkgrid(frame, sticky="w", columnspan=2)      
    OKbutton <- tkbutton(top, text="OK", fg="darkgreen", width="12",
command=onOK, default="active",
            borderwidth=3)
    cancelButton <- tkbutton(top, text="Cancel", fg="darkgreen", width="12",
command=onCancel,
            borderwidth=3)
    tkgrid(OKbutton, cancelButton, sticky="w")
    tkgrid.rowconfigure(top, 0, weight=0)
    tkgrid.columnconfigure(top, 0, weight=0)
    tkgrid.columnconfigure(top, 1, weight=0)
    .Tcl("update idletasks")
    tkwm.resizable(top, 0, 0)
    tkbind(top, "<Return>", onOK)
    tkwm.deiconify(top)
    tkgrab.set(top)
    tkfocus(top)
    tkwait.window(top)
    }
    
The arguments I use to install.packages aren't that well thought out; e.g.,
I set the destdir directly to suppress the prompt in the Console to delete
the downloaded files. Of course, in the application we're discussing, it
would be natural to supply the packages to install (and their location?).

> > On the other hand, if a user doesn't have an active Internet 
> > connection, how likely is it that he or she will be able to install 
> > missing packages?
> 
> Very likely for our workshops.  Many I.T. departments are 
> becoming more strict about not letting outsiders connect up 
> their laptops to the local network because of fears of 
> viruses and trojans.  So if we present a microarray workshop 
> at a conference where people bring their own laptops, we 
> provide a CD containing all of the necessary R packages for 
> participants who have failed to install the correct software 
> beforehand.
> 

I provide students with a similar CD. I usually include a live version of R
with everything installed and a (Windows) batch file to run the R installer
and copy over packages and configuration files. 

Regards,
 John

> Regards,
> James
> 
> _______________________________________________
> R-SIG-GUI mailing list
> R-SIG-GUI at stat.math.ethz.ch
> https://www.stat.math.ethz.ch/mailman/listinfo/r-sig-gui



More information about the R-SIG-GUI mailing list