The interface objects are divided into three categories:
- User Control object (Uicontrol)
- Drop-down Menu object (Uimenu)
- Content-Style Menu object (uicontextmenu)
To create a user interface:
1. Command-line mode
Use Uicontrol to create a control object. Used in
- Handle=uicontrol (parent)
- Handle=uicontrol (..., ' property name ', property value, ' property name ', property value,...)
Ex17-1:
H=uicontrol (' style ',' pushbutton ', 'Units ',' normalized ',' Position ', [. 5.5.2.1],' String ',' Click here ',' Callback ',' Set (H, ' Position ', [. 8*rand. 9*rand. 2. 1]);
2.GUI Design Tools
Slightly
All handle graphic images have a BUTTONDOWNFCN property, most UI objects also have a callback property, a KEYPRESSFCN property for Uicontrol objects, and a graphical object from WINDOWSBUTTONDOWNFCN, WINDOWBUTTONUPFCN and so on attributes.
To execute the button's click command on the Buttons object, you can set it to:
H_uic=uicontrol (' Style ', ' pushbutton ', ' Callback ', ' BUTTONFCN click ')
Ex17-3:
The qualifying conditions are added in the first two edit callback:
Input=str2num (get(hobject,' String ')); The% check is null if empty, shown as 0if (IsEmpty (input)) set(hobject,' String ', ' 0 ' ) Endguidata (hobject,handles);
A calculated event was added to the callback of the button:
A=Get(handles.edit1,' string'); b=get(handles.edit2,' string '); Total =str2num (a) +Str2Num (b), c=num2str (total); % Update calculation result set(handles.edit3,' String ', c); the% update graphic object handle, the general callback callback function has guidata (hobject,handles) to end the updated data. Guidata (hobject,handles);
2014.04.16, reading, reading notes-"Matlab r2014a fully self-taught a pass"-17th Chapter Graphical user interface