你如何将tcltk消息框放在R的顶层?

时间:2017-06-02 09:26:17

标签: r

有人可以告诉我如何给'tcltk'消息框顶级焦点在R?

我的MWE低于。如果您运行代码并拖动消息框,您将看到它总是落后于基本窗口(代表我的应用程序的主窗口)。

library(tcltk)

base = tcltk::tktoplevel()
tcltk::tcl("wm", "attributes", base, topmost = TRUE)

loadYN <- tcltk::tkmessageBox(title = "",
                            message = "I really wish I appeared at the top 
level :(",
                            icon = "question", type = "yesno", default = 
"no")

提前感谢您的帮助!

编辑:我找到了解决方法(虽然我仍然想象有更好的方法)。我只是操纵topmost函数中包含的tcl参数来实现我的需要:

library(tcltk)

base = tcltk::tktoplevel()
tcltk::tcl("wm", "attributes", base, topmost = TRUE)

# Changing focus of base frame 
tcltk::tcl("wm", "attributes", base, topmost = FALSE)

loadYN <- tcltk::tkmessageBox(title = "",
                            message = "I really wish I appeared at the top 
level :(",
                            icon = "question", type = "yesno", default = 
"no")

# Changing focus of base frame
tcltk::tcl("wm", "attributes", base, topmost = TRUE)

这是一种解决方法,可以实现我的需要,但不会回答我原来的问题,所以仍在寻找答案:)

0 个答案:

没有答案