【问题标题】:how to bring the choose.file() dialog to the foreground如何将 choose.file() 对话框置于前台
【发布时间】:2011-10-28 16:47:15
【问题描述】:

我在 Windows XP 下通过 rscript.exe 运行的脚本中使用了函数 choose.dir()。问题是目录选择对话框没有作为顶级窗口弹出。如何将对话带到前台?

与此同时,我通过使用 Visual Basic 脚本解决了我的问题。当然,这只适用于 windows:

tf <- tempfile(fileext = '.vbs')
cat('Set folder = CreateObject("Shell.Application") _
        .BrowseForFolder(0, "Please choose a folder" _
       , &H0001, 17)
       Wscript.Echo folder.Self.Path
', file = tf)
tail(shell(paste('Cscript', tf), intern = T), 1)

【问题讨论】:

  • 非常感谢 vbs 解决方案!我对choose.file() 有同样的问题。你能为此提供 vbs 代码吗?

标签: user-interface r dialog


【解决方案1】:

搜索 rhelp 档案后,答案似乎是您不能在非交互式会话中使用 choose.dirfile.choose。您也许可以做类似的事情,因为 list.filesfile.infofile.accessfiles 可用于收集信息,您可以通过写入图形设备并执行 system() 调用来显示此信息让它显示出来,readLines 可以用来获取用户输入。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-18
    • 1970-01-01
    • 1970-01-01
    • 2020-07-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多