I'm currently creating a GUI using mathlab GUIDE. Since the GUI is very slow I'd like to add an edit_text
uicontrol in order to show whether the GUI is running or not.
For instance I have a push_button
that changes the plot in an axes. When the user click on this button the GUI takes several seconds to perform the new plot. What I want to do is setting the edit_text
with the string 'running'
as soon as the button was pressed. When the callback is done and the plot plotted I'd like to set the edit_text
with another string : 'ready'
.
I used the following code :
function push_button_Callback(hObject, eventdata, handles)
% hObject handle to push_button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.edit_text,'String','Running...');
%a bunch of code...
set(handles.edit_text,'String','Ready.');
guidata(hObject,handles);
I hoped that once the callback is called, the GUI would display 'running...'
on my edit_text
. Apparently I was wrong. When running the GUI and pressing the push_button
the plot changes but the edit_text
remains the same.
Then I tried something else using the ButtonDownFcn
callback. My idea was that the latter callback would be executed before the actual callback (written above). Here is the code :
function push_button_ButtonDownFcn(hObject, eventdata, handles)
% hObject handle to push_button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.edit_text,'String','Running...');
guidata(hObject,handles);
The problem is that the ButtonDownFcn
callback isn't executed every time. As GUIDE says about the latter callback :
% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over str22.
Obviously I want my push_button
to be enabled, otherwise it won't work the way I want. So I don't know what else to try.
Has someone any idea how I could manage to do that ?