处理时 RGTK2 阻止用户输入 [英] RGTK2 block user input while processing
问题描述
我用 R 语言用 RGTK2 和 Tcltk 编写了一个 GUI,它在大数据集上进行了大量相当繁重的计算和聚合.
I have written a GUI in R with RGTK2 and Tcltk that does a lot of fairly heavy calculations and aggregations on big data sets.
我想找到一种方法来阻止用户界面在处理大型数据集时接受用户输入,理想情况下,更改界面颜色、弹出对话框或将鼠标指针更改为沙漏/微调器向用户表明应用程序处于活动状态.
I would like to find a way to stop the user interface from accepting user inputs while it is processing a large data set, and ideally, change the interface color, popup a dialogue, or change the mouse pointer to an hourglass/spinner to indicate to users that the application is active.
我想要的实现看起来像:
The implementation that I want would look something like:
gSignalConnect(bigRedButton,"clicked",
f=function(widget)
{
something$start() # object with method that blocks further user input
# and pops up loading bar or "Processing" dialogue
# (or possibly spins the mouse)
# Code that does a very big set of calculations
something$stop() # unblocks user inputs and removes visual impedance
}
)
我曾尝试使用 gtkDialogue 来解决这个问题,但这似乎会停止整个程序的执行,直到关闭对话,这反而违背了目的.
I have tried using gtkDialogue to solve the problem, but this seems to stop execution of the whole program until one closes the dialogue, which rather defeats the purpose.
任何帮助将不胜感激.
推荐答案
所以神奇的方法是gtkWidgetSetSensitive:
So the magic method is gtkWidgetSetSensitive:
gSignalConnect(bigRedButton,"clicked",
f=function(widget)
{
gtkWidgetSetSensitive(Window,FALSE)
# Code that does a very big set of calculations
gtkWidgetSetSensitive(Window,TRUE)
}
)
此方法将目标小部件(可以是单个按钮、textEntry、comboBox 等)变灰并阻止输入.
This method turns the targeted widget (which can be an individual button, textEntry, comboBox, etc...) gray and blocks input.
这篇关于处理时 RGTK2 阻止用户输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!