How to make a "Do not touch!" dialog box?
2 ビュー (過去 30 日間)
古いコメントを表示
I have a GUI where there are several pushbuttons, selection boxes, etc. By pushing pushbuttons the program calculates something which can be quite long. Users are impatient. When there is no sign of activity on the GUI, they tend to think something is going wrong, so they try to push a different button, then another etc. When the program finishes calculation, it serves the next pushbutton, then the next etc. (depending on how many were pushed by the user). It could be other long calculations and the program is doing one after the second and apparently it becomes insensitive to any user interaction. So the user is complaining that the program "was frozen".
I would like to have a dialogue window, saying that "I am calculating" or something like that, and it would prevent any keyboard or mouse interaction to the main program. Also, it should not let the user close it. It also should let the background calculations go in the GUI.
I have tried different dialog boxes available in MATLAB. All of them either suspend the background calculation, waiting for user interaction or they do not prevent user interaction to the main GUI, and all of them can be closed by the user.
Is there any way to solve this problem?
0 件のコメント
回答 (2 件)
Matt J
2018 年 2 月 25 日
編集済み: Matt J
2018 年 2 月 25 日
You can make the GUI button non-Interruptible using its Interruptible property (if this is a GUIDE GUI). See also Controlling Callback Interruption.
You should in any case disable the other buttons (using their Enable property) while the computation is in progress, and maybe use waitbar() to let the user view the current state of the computation.
Image Analyst
2018 年 2 月 25 日
What I do is disable all controls, except my exit button, and change the cursor to a wait cursor (spinning blue circle in Windows):
% Change mouse pointer (cursor) to the wait cursor.
set(gcf,'Pointer','watch');
drawnow; % Cursor won't change right away unless you do this.
then I re-enable the controls and change the cursor back to normal.
% Change mouse pointer (cursor) to an arrow.
set(gcf,'Pointer','arrow');
drawnow; % Cursor won't change right away unless you do this.
The attached functions to enable or disable all controls on the window may help.
I'm not aware of the "Interruptible property" Matt mentioned. That may be a better approach - I just don't know because I haven't used it.
参考
カテゴリ
Help Center および File Exchange で Dialog Boxes についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!