资源描述:
《简单计算器的GUI设计.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、简单计算器的GUI设计运行结果:源代码:functionvarargout=jisuanji(varargin)gui_Singleton=1;gui_State=struct('gui_Name',mfilename,...'gui_Singleton',gui_Singleton,...'gui_OpeningFcn',@jisuanji_OpeningFcn,...'gui_OutputFcn',@jisuanji_OutputFcn,...'gui_LayoutFcn',[],...'gui_Callback',[]
2、);ifnargin&&ischar(varargin{1})gui_State.gui_Callback=str2func(varargin{1});endifnargout[varargout{1:nargout}]=gui_mainfcn(gui_State,varargin{:});elsegui_mainfcn(gui_State,varargin{:});endfunctionjisuanji_OpeningFcn(hObject,eventdata,handles,varargin)handles.output
3、=hObject;guidata(hObject,handles);functionvarargout=jisuanji_OutputFcn(hObject,eventdata,handles)varargout{1}=handles.output;%---Executesonbuttonpressinpushbutton1.functionpushbutton1_Callback(hObject,eventdata,handles)%乘号“×”键的回调函数;signs=get(handles.edit1,'string')
4、;set(handles.edit1,'string',strcat(signs,'*'));%---Executesonbuttonpressinpushbutton2.functionpushbutton2_Callback(hObject,eventdata,handles)%除号“÷”键的回调函数;signs=get(handles.edit1,'string');set(handles.edit1,'string',strcat(signs,'/'));%---Executesonbuttonpressinpush
5、button3.functionpushbutton3_Callback(hObject,eventdata,handles)%---Executesonbuttonpressinpushbutton4.functionpushbutton4_Callback(hObject,eventdata,handles)%加号“+”键的回调函数;signs=get(handles.edit1,'string');set(handles.edit1,'string',strcat(signs,'+'));%---Executesonb
6、uttonpressinpushbutton6.functionpushbutton6_Callback(hObject,eventdata,handles)%减号“-”键的回调函数;signs=get(handles.edit1,'string');set(handles.edit1,'string',strcat(signs,'-'));%---Executesonbuttonpressinpushbutton7.functionpushbutton7_Callback(hObject,eventdata,handles
7、)%数字键7的回调函数:numbers=get(handles.edit1,'string');set(handles.edit1,'string',strcat(numbers,'7'));%---Executesonbuttonpressinpushbutton8.functionpushbutton8_Callback(hObject,eventdata,handles)%数字键4的回调函数:numbers=get(handles.edit1,'string');set(handles.edit1,'string',s
8、trcat(numbers,'4'));%---Executesonbuttonpressinpushbutton9.functionpushbutton9_Callback(hObject,eventdata,handles)%数字键1的回调函数:numbers=get(handles.