tags:

views:

35

answers:

2

I'm working on a gui using GUIDE in MATLAB, and from what I've read it looks like MATLAB updates the UI controls based on a timer every so often. Is there a way to force it to update the UI controls, so I can make it update in the middle of the function? Right now I have a function that does, simplifed, something like

set(handles.lblStatus,'String','Processing...')
%function that takes a long time
set(handles.lblStatus,'String','Done')

Since MATLAB doesn't update the GUI during a Callback function, the user only ever sees 'Done' after a long period of waiting and never sees 'Processing'. I tried adding guidata(hObject, handles) after the first set, hoping it would force the screen to update, but it doesn't.

+3  A: 

Try calling DRAWNOW.

set(handles.lblStatus,'String','Processing...')
drawnow
%function that takes a long time
set(handles.lblStatus,'String','Done')
Jonas
Thanks! That fixed 'er right up. :)
Alex Zylman
A: 

I believe there is a drawnow function in matlab.

drawnow completes pending drawing events

neXus
I have never quite really understood why people duplicate the information in previous answers as new answers.
Andreas Rejbrand
I think it's fine if you give a better description, or more examples, or more links, or they're within a couple minutes so maybe it wasn't there when you're loading the page, but it's not fine when it's 10 minutes later and worse.
Alex Zylman
Yeah, something else needed my attention while I was answering. Sorry for being late
neXus

related questions