gWidgets - ginput() function error

2019-09-16 04:11发布

问题:

I'm having a problem with launching the ginput pop-up from gWidgets.

This is the error:

Loading required package: gWidgetstcltk Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘.ginput’ for signature ‘"guiWidgetsToolkittcltk"’ In addition: Warning message: In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, : there is no package called ‘gWidgetstcltk’

I use the popup to type a number that I then assign to a variable.

Code snippet as follows:

options(guiToolkit = "tcltk") # Tool kit dependency for gwidgets.
library(gWidgets) # Package required to launch ginput gui.

width.var <- as.numeric(ginput("Enter value for - Width        ",
                               title = "PNG dimensions", 
                               icon = "info"))

Supplementary info:

I updated my R version from 3.2.5 to 3.4.1 as well as installing the latest RStudio version. I've run this code section before on R3.4.1 but on a different computer without any issues.

Right now i suspect it's RStudio but i don't know how to fix it.

Any help is greatly appreciated.

Alex

ANSWER:

The error threw me a bit and looks more complicated than it really is.

I fixed by simply installing "gWidgetstcltk". I assumed that because I load tcltk and gWidgets separately that it would be enough. Thanks Alex

回答1:

Please see original post for the fix. Best,

Alex