gpt4 book ai didi

r - 使用 tcltk 在 R 脚本中添加弹出文本框

转载 作者:行者123 更新时间:2023-12-04 17:38:16 24 4
gpt4 key购买 nike

我有一个很长的脚本来做一些数据分析,它必须连接到几个数据库。其中一个数据库往往比我喜欢的更频繁地更新我的密码,所以我想添加一个弹出框让我输入我当前的密码。我找到了这个例子,但不理解足够的 tcltk 来看到 hwo 在对话框被关闭时返回我的值。我想过在 OnOK 函数中将其定义为全局变量( <<- ),但这似乎很困惑

require(tcltk)
tt<-tktoplevel()
Name <- tclVar("Password")
entry.Name <-tkentry(tt,width="20",textvariable=Name)
tkgrid(tklabel(tt,text="Enter Password"))
tkgrid(entry.Name)
OnOK <- function()
{
NameVal <- tclvalue(Name)
tkdestroy(tt)
}
OK.but <-tkbutton(tt,text=" OK ",command=OnOK)
tkbind(entry.Name, "<Return>",OnOK)
tkgrid(OK.but)
tkfocus(tt)

最佳答案

你回答了你自己的问题:你确实需要 <<-在这些 tcltk 示例中——请参阅 Peter 多年来的各种帖子,或其他漂浮的示例,使用其他 CRAN 包,甚至包本身。尝试

  library(tcltk)
demo("tkcanvas")

看看它是如何处理的,例如 lastX , lastY .

关于r - 使用 tcltk 在 R 脚本中添加弹出文本框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11311747/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com