简体   繁体   English

如何摆脱tcltk2软件包的副作用?

[英]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: 使用tcltk2库在R中创建GUI窗口后,当我恢复为使用由依赖于tcltk的软件包(不包含2)生成的窗口时,在Windows 7上收到以下错误消息:

Error in col2rgb(col) : invalid color name 'SystemButtonFace' col2rgb(col)中的错误:无效的颜色名称'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. 必须是tcltk2更改了一些用于在R中使用GUI的基本选项,因为在加载tcltk2之前不存在错误消息。 I am working with the following version of R: 我正在使用以下版本的R:

R version 3.1.0 (2014-04-10) -- "Spring Dance" R版本3.1.0(2014-04-10)-“春舞”

Is there a way to deal with this side effect (ie, remove it)? 有没有办法解决这种副作用(即,将其消除)?

I tried to simply detach the tcltk2 package (which is a supplement to the tcltk package), but that doesn't do it. 我试图简单地分离tcltk2软件包(这是对tcltk软件包的补充),但是并没有做到这一点。

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). 我还尝试过在GUI窗口中替换生成错误消息的颜色,并使用R颜色名称(如“红色”和“蓝色”(而不是#CCCFFF之类的颜色))来生成错误消息。

Any help would be greatly appreciated. 任何帮助将不胜感激。

Thanks, 谢谢,

Isabella 伊莎贝拉

It is not just an annoyance - it prevents R from properly displaying subsequent GUI windows. 这不仅是烦人的事-它阻止R正确显示后续的GUI窗口。

I've put together some example R code. 我整理了一些示例R代码。 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). 该代码使用PBSmodelling包来创建R GUI窗口(该包取决于tcltk而不取决于tcltk2,这两个都是R包)。 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: 如此创建的GUI窗口正确显示在R中。但是,在将tcltk2程序包加载到R中并尝试再次显示相同的窗口后,出现错误消息:

Error in col2rgb(col) : invalid color name 'SystemButtonFace' col2rgb(col)中的错误:无效的颜色名称'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. 为了给您一些背景,到目前为止,我为我的项目编写的大多数R GUI窗口都依赖PBSmodelling,并且运行良好。 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. 我只需要使用tcltk2为项目创建几个窗口,但是由于上述错误消息,这些窗口(至少目前)无法与其他大多数窗口集成。

Here is the R code that will reproduce the error message: 这是将重现错误消息的R代码:

## 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 伊莎贝拉

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM