Add a popup text box within an R script using tcltk

后端 未结 3 1478
难免孤独
难免孤独 2021-01-13 02:22

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,

相关标签:
3条回答
  • 2021-01-13 03:03

    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.

    0 讨论(0)
  • 2021-01-13 03:05

    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.

    0 讨论(0)
  • 2021-01-13 03:14

    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.

    0 讨论(0)
提交回复
热议问题