Isabella Ghement
Isabella Ghement

Reputation: 775

How to get rid of side effect of tcltk2 package?

After working with the tcltk2 library to create a GUI window in R, when I revert to using a window produced with a package which depends on tcltk (without the 2), I get this error message on Windows 7:

Error in col2rgb(col) : invalid color name 'SystemButtonFace'

It must be that tcltk2 changes some underlying options for working with GUIs in R, because the error message is absent prior to loading tcltk2. I am working with the following version of R:

R version 3.1.0 (2014-04-10) -- "Spring Dance"

Is there a way to deal with this side effect (i.e., remove it)?

I tried to simply detach the tcltk2 package (which is a supplement to the tcltk package), but that doesn't do it.

I also tried replacing the colours in the GUI window that generated the error messages with R colour names like "red" and "blue" (instead of colours like #CCCFFF).

Any help would be greatly appreciated.

Thanks,

Isabella

Upvotes: 1

Views: 340

Answers (1)

Isabella Ghement
Isabella Ghement

Reputation: 775

It is not just an annoyance - it prevents R from properly displaying subsequent GUI windows.

I've put together some example R code. The code uses the PBSmodelling package to create an R GUI window (where the package depends on tcltk but not on tcltk2, both of which are R packages). The GUI window thus created is properly displayed in R. However, after loading the tcltk2 package in R and trying to display the same window again, I get the error message:

Error in col2rgb(col) : invalid color name 'SystemButtonFace'

To give you some context, most of the R GUI windows I've written for my project so far rely on PBSmodelling and work fine. I only need to use tcltk2 to create a couple of windows for the project, but these windows cannot (at least at the moment) be integrated with the majority of the other windows because of the above mentioned error message.

Here is the R code that will reproduce the error message:

## install & require PBSmodelling package 
## for creating R GUI windows
install.packages("PBSmodelling")
require(PBSmodelling)

## function to plot a sinusoid (to be called by GUI window) 
myPlot <- function() { 
        getWinVal(scope="L"); 
        x <- seq(0,500)*2*n*pi/500; 
        plot(x,sin(x),type="l"); 
} 

## create an R GUI window with PBSmodelling 
winStr=c( "window title=Simple", 
      "entry name=n value=5", 
      "button function=myPlot text=\"Plot sinusoid\"")

## display R GUI window created with PBSmodelling 
createWin(winStr,astext=TRUE)

## install & require tcltk2 package 
install.packages("tcltk2")
require(tcltk2)

## try to display R GUI window created with PBSmodelling, 
## this time after loading the tcltk2 package in R 
createWin(winStr,astext=TRUE)

## Error message:
## Error in col2rgb(col) : invalid color name 'SystemButtonFace'

If you have any ideas for resolving this issue, please let me know.

Many thanks,

Isabella

Upvotes: 1

Related Questions