this is what i mean by running in the GUI
Pause button for GUI
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi,
My gui runs a plotting fucntion i created for some txt data. with a start, pause and stop button, i dont know how to make the while loop for it to stop but,
I am using the following for a pause button, it works , however when i press it it continues to run the called function on the actual gui. Is there a way to stop that?
% --- Executes on button press in Pause.
function Pause_Callback(hObject, eventdata, handles)
% hObject handle to Pause (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(gcbo,'userdata',1)
% --- Executes on key press with focus on Start and none of its controls.
function Start_KeyPressFcn(hObject, eventdata, handles)
% hObject handle to Start (see GCBO)
% eventdata structure with the following fields (see MATLAB.UI.CONTROL.UICONTROL)
% Key: name of the key that was pressed, in lower case
% Character: character interpretation of the key(s) that was pressed
% Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
% handles structure with handles and user data (see GUIDATA)
% function browse_data()
% [filename, pathname] = uigetfile('.txt');
% set( yourEditHandle, 'String', filename);
%
i=1;
while i
drawnow
if get(handlepushbutton,'userdata'); % stop condition
break;
end
i=i+1;
end
3 comentarios
Respuestas (1)
Alex Mcaulley
el 27 de Mayo de 2019
Following your code, for example (The property 'Interruptible' of the start button must be set to 'on'):
% --- Executes on button press in Pause.
function Pause_Callback(hObject, eventdata, handles)
% hObject handle to Pause (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if isempty(get(hObject,'UserData'))
set(hObject,'UserData',1)
else
set(hObject,'UserData',~get(hObject,'UserData'))
end
guidata(hObject, handles);
% --- Executes on key press with focus on Start and none of its controls.
function Start_KeyPressFcn(hObject, eventdata, handles)
% hObject handle to Start (see GCBO)
% eventdata structure with the following fields (see MATLAB.UI.CONTROL.UICONTROL)
% Key: name of the key that was pressed, in lower case
% Character: character interpretation of the key(s) that was pressed
% Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
% handles structure with handles and user data (see GUIDATA)
% function browse_data()
% [filename, pathname] = uigetfile('.txt');
% set( yourEditHandle, 'String', filename);
%
i=1;
while i
drawnow
if get(handles.waitPushButton,'UserData'); % stop condition
waitfor(handles.waitPushButton,'Value',0) %Waits for another click on wait pushbutton
end
i=i+1;
end
0 comentarios
Ver también
Categorías
Más información sobre Creating, Deleting, and Querying Graphics Objects en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!