How to indicate that GUI is busy running?

조회 수: 119 (최근 30일)
Kyle
Kyle 2011년 7월 12일
편집: Walter Roberson 2020년 8월 31일
I would like to know how to indicate in my GUI that MATLAB is currently busy running some piece of code (e.g. a long computation). Currently, there is no indication in the GUI that the code is running, causing the user to wonder whether it is working or just not responsive.

채택된 답변

Titus Edelhofer
Titus Edelhofer 2011년 7월 12일
Hi Kyle,
two typical main ways to do this: in your callback do
set(handles.figure1, 'pointer', 'watch')
drawnow;
% your computation
set(handles.figure1, 'pointer', 'arrow')
This shows the hour glass during the callback. If the callback indeed takes longer, use function "waitbar" to indicate progress ...
Titus
  댓글 수: 4
Aash
Aash 2018년 5월 4일
I tried doing this and it is giving this error Error using matlab.ui.control.UIControl/set There is no pointer property on the UIControl class.
Error in Control>error_Callback (line 435) set(handles.error, 'pointer', 'watch')
What does it mean?
Walter Roberson
Walter Roberson 2020년 7월 8일
You can only set the Pointer for a figure, not for a uicontrol.
fig = ancestor(handles.error, 'figure');
oldpointer = get(fig, 'pointer');
set(fig, 'pointer', 'watch');
drawnow;
% your computation goes here
set(fig, 'pointer', oldpointer)

댓글을 달려면 로그인하십시오.

추가 답변 (3개)

Kyle
Kyle 2011년 7월 12일
btw how to use function "waitbar" to indicate progress.
does matlab know to compute the time its going to be busy?
  댓글 수: 1
Sean de Wolski
Sean de Wolski 2011년 7월 12일
You have to manually update waitbar - look at the example in
doc waitbar

댓글을 달려면 로그인하십시오.


Aash
Aash 2018년 5월 9일
My pointer is changing to the loading while computation but it isnt coming back to the orignal arrow after the code stops executing. Here is my code
oldpointer = get(handles.figure1, 'pointer');
set(handles.figure1, 'pointer', 'watch')
drawnow;
%code that runs
set(handles.figure1, 'pointer', oldpointer)
  댓글 수: 2
Ahmer Shahid
Ahmer Shahid 2019년 1월 13일
How can I use this in app designer?
it's giving me error.
Error using matlab.ui.Figure/set
Functionality not supported with figures created with the uifigure function. For more information, see Graphics Support in App Designer.
syed Rahim
syed Rahim 2020년 6월 12일
isn't handles a GUIDE only graphics structure. For APP designer it should be App.Figure1.

댓글을 달려면 로그인하십시오.


Jan Siegmund
Jan Siegmund 2020년 7월 8일
편집: Jan Siegmund 2020년 8월 31일
Users that looked for a waitbar style solution should have a look at https://de.mathworks.com/help/matlab/ref/uiprogressdlg.html which is basically waitbar but with an up to date look.

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by