Advertisement
Guest User

GUI experiment

a guest
Mar 30th, 2015
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 5.10 KB | None | 0 0
  1. function varargout = untitled(varargin)
  2. % UNTITLED MATLAB code for untitled.fig
  3. %      UNTITLED, by itself, creates a new UNTITLED or raises the existing
  4. %      singleton*.
  5. %
  6. %      H = UNTITLED returns the handle to a new UNTITLED or the handle to
  7. %      the existing singleton*.
  8. %
  9. %      UNTITLED('CALLBACK',hObject,eventData,handles,...) calls the local
  10. %      function named CALLBACK in UNTITLED.M with the given input arguments.
  11. %
  12. %      UNTITLED('Property','Value',...) creates a new UNTITLED or raises the
  13. %      existing singleton*.  Starting from the left, property value pairs are
  14. %      applied to the GUI before untitled_OpeningFcn gets called.  An
  15. %      unrecognized property name or invalid value makes property application
  16. %      stop.  All inputs are passed to untitled_OpeningFcn via varargin.
  17. %
  18. %      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
  19. %      instance to run (singleton)".
  20. %
  21. % See also: GUIDE, GUIDATA, GUIHANDLES
  22.  
  23. % Edit the above text to modify the response to help untitled
  24.  
  25. % Last Modified by GUIDE v2.5 06-Apr-2015 18:02:24
  26.  
  27. % Begin initialization code - DO NOT EDIT
  28. gui_Singleton = 1;
  29. gui_State = struct('gui_Name',       mfilename, ...
  30.                    'gui_Singleton',  gui_Singleton, ...
  31.                    'gui_OpeningFcn', @untitled_OpeningFcn, ...
  32.                    'gui_OutputFcn',  @untitled_OutputFcn, ...
  33.                    'gui_LayoutFcn',  [] , ...
  34.                    'gui_Callback',   []);
  35. if nargin && ischar(varargin{1})
  36.     gui_State.gui_Callback = str2func(varargin{1});
  37. end
  38.  
  39. if nargout
  40.     [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
  41. else
  42.     gui_mainfcn(gui_State, varargin{:});
  43. end
  44. % End initialization code - DO NOT EDIT
  45.  
  46.  
  47. % --- Executes just before untitled is made visible.
  48. function untitled_OpeningFcn(hObject, eventdata, handles, varargin)
  49. % This function has no output args, see OutputFcn.
  50. % hObject    handle to figure
  51. % eventdata  reserved - to be defined in a future version of MATLAB
  52. % handles    structure with handles and user data (see GUIDATA)
  53. % varargin   command line arguments to untitled (see VARARGIN)
  54.  
  55. % Choose default command line output for untitled
  56. handles.output = hObject;
  57.  
  58. % Update handles structure
  59. guidata(hObject, handles);
  60.  
  61. % UIWAIT makes untitled wait for user response (see UIRESUME)
  62. % uiwait(handles.figure1);
  63.  
  64.  
  65. % --- Outputs from this function are returned to the command line.
  66. function varargout = untitled_OutputFcn(hObject, eventdata, handles)
  67. % varargout  cell array for returning output args (see VARARGOUT);
  68. % hObject    handle to figure
  69. % eventdata  reserved - to be defined in a future version of MATLAB
  70. % handles    structure with handles and user data (see GUIDATA)
  71.  
  72. % Get default command line output from handles structure
  73. varargout{1} = handles.output;
  74.  
  75.  
  76.  
  77. function edit1_Callback(hObject, eventdata, handles)
  78. % hObject    handle to edit1 (see GCBO)
  79. % eventdata  reserved - to be defined in a future version of MATLAB
  80. % handles    structure with handles and user data (see GUIDATA)
  81.  
  82. % Hints: get(hObject,'String') returns contents of edit1 as text
  83. %        str2double(get(hObject,'String')) returns contents of edit1 as a double
  84.  
  85.  
  86. % --- Executes during object creation, after setting all properties.
  87. function edit1_CreateFcn(hObject, eventdata, handles)
  88. % hObject    handle to edit1 (see GCBO)
  89. % eventdata  reserved - to be defined in a future version of MATLAB
  90. % handles    empty - handles not created until after all CreateFcns called
  91.  
  92. % Hint: edit controls usually have a white background on Windows.
  93. %       See ISPC and COMPUTER.
  94. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  95.     set(hObject,'BackgroundColor','white');
  96. end
  97.  
  98.  
  99.  
  100. function edit2_Callback(hObject, eventdata, handles)
  101. % hObject    handle to edit2 (see GCBO)
  102. % eventdata  reserved - to be defined in a future version of MATLAB
  103. % handles    structure with handles and user data (see GUIDATA)
  104.  
  105. % Hints: get(hObject,'String') returns contents of edit2 as text
  106. %        str2double(get(hObject,'String')) returns contents of edit2 as a double
  107.  
  108.  
  109. % --- Executes during object creation, after setting all properties.
  110. function edit2_CreateFcn(hObject, eventdata, handles)
  111. % hObject    handle to edit2 (see GCBO)
  112. % eventdata  reserved - to be defined in a future version of MATLAB
  113. % handles    empty - handles not created until after all CreateFcns called
  114.  
  115. % Hint: edit controls usually have a white background on Windows.
  116. %       See ISPC and COMPUTER.
  117. if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
  118.     set(hObject,'BackgroundColor','white');
  119. end
  120.  
  121.  
  122. % --- Executes on button press in pushbutton1.
  123. function pushbutton1_Callback(hObject, eventdata, handles)
  124. % hObject    handle to pushbutton1 (see GCBO)
  125. % eventdata  reserved - to be defined in a future version of MATLAB
  126. % handles    structure with handles and user data (see GUIDATA)
  127. x1= str2double(get(handles.edit1,'String'));
  128. x2= str2double(get(handles.edit2,'String'));
  129. x3= x1+x2;
  130. set(handles.text1,'String',x3);
  131. guidata(hObject,handles);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement