I have a long-ish script to do some data analysis, and it has to connect to several databases. One of the databases tends to update my password more frequently than I like,
You answered your own question: you do in fact need <<-
in these tcltk examples---see the various posts by Peter over the years, or other examples floating around, other CRAN packages using, or even in the package itself. Try
library(tcltk)
demo("tkcanvas")
and see how it treats e.g. lastX
, lastY
.
You can use the tkwait.window
or tkwait.variable
functions. Use the above code to pop-up the window, then use one of the wait functions (tkwait.window
will stop the script from proceeding until the window is destroyed, essentially when you click on OK). Then when the script proceeds you will have your value in the variable within the script/function and can just use it there without needing to assign a global variable.
You might find the ginput
function of gWidgets
wraps up what Greg Snow suggests for you:
require(gWidgets)
options(guiToolkit="tcltk")
NameVal <- ginput("Enter your passsword:")
NameVal
will contain the entered string or NA
if you cancel.