
10 Examples of GUIDE GUIs
10-30
• The which command returns the full path to the file when it is on the
MATLAB path
• The
web command displays the file in the Help browser.
This is the
Help button callback.
function HelpButton_Callback(hObject, eventdata, handles)
HelpPath = which('f14ex_help.html');
web(HelpPath);
You can also display the help document in a Web browser or load an external
URL. See the Web documentation for a description of these options.
Closing the GUI
The GUI Close button callback closes the plot figure, if one exists and then
closes the GUI. The handle of the plot figure and the GUI figure are available
from the
handles structure. The callback executes two steps:
• Checks to see if there is a
PlotFigure field in the handles structure and if it
contains a valid figure handle (the user could have closed the figure
manually).
• Closes the GUI figure
This is the
Close button callback.
function CloseButton_Callback(hObject, eventdata, handles)
% Close the GUI and any plot window that is open
if isfield(handles,'PlotFigure') && ...
ishandle(handles.PlotFigure),
close(handles.PlotFigure);
end
close(handles.F14ControllerEditor);
The List Box Callback and Create Function
This GUI does not use the list box callback since the actions performed on list
box items are carried out by push buttons (
Simulate and store results,
Remove, and Plot). However, GUIDE automatically inserts a callback stub
when you add the list box and automatically sets the
Callback property to
execute this subfunction whenever the callback is triggered (which happens
when users select an item in the list box).
Commenti su questo manuale