
Initialization Callbacks
8-15
Initialization Callbacks
GUIDE automatically includes two callbacks, the opening function and the
output function, in every GUI M-file it creates.
• “Opening Function” on page 8-15
• “Output Function” on page 8-17
For information about programming component callbacks, see “Examples:
Programming GUI Components” on page 8-19.
Opening Function
The opening function is the first callback in every GUI M-file. It is executed just
before the GUI is made visible to the user, but after all the components have
been created, i.e., after the components’
CreateFcn callbacks, if any, have been
run.
You can use the opening function to perform your initialization tasks before the
user has access to the GUI. For example, you can use it to create data or to read
data from an external source. GUI command line arguments are passed to the
opening function.
• “Function Naming and Template” on page 8-15
• “Input Arguments” on page 8-16
• “Initial Template Code” on page 8-16
Function Naming and Template
GUIDE names the opening function by appending _OpeningFcn to the name of
the M-file. This is an example of an opening function template as it might
appear in the
mygui M-file.
% --- Executes just before mygui is made visible.
function mygui_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to mygui (see VARARGIN)
Commentaires sur ces manuels