RGTK2 block user input while processing

∥☆過路亽.° 提交于 2019-12-12 04:57:17

问题


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
}
)

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.

Any help would be greatly appreciated.


回答1:


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)
}
)

This method turns the targeted widget (which can be an individual button, textEntry, comboBox, etc...) gray and blocks input.



来源:https://stackoverflow.com/questions/19061986/rgtk2-block-user-input-while-processing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!