필터 지우기
필터 지우기

Wait for user input after pressing button

조회 수: 6 (최근 30일)
monkey_matlab
monkey_matlab 2016년 4월 20일
답변: Meade 2016년 4월 20일
Hello,
I created a "OK" button using the guide template in Matlab. Here is the code:
function varargout = prompt11(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @prompt11_OpeningFcn, ...
'gui_OutputFcn', @prompt11_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
function prompt11_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
function varargout = prompt11_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
function pushbutton1_Callback(hObject, eventdata, handles)
function edit1_Callback(hObject, eventdata, handles)
function edit1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
How can I go about pausing my program until the user hits the "OK" button?
My code looks like this:
prompt11
my code
my code
my code

답변 (1개)

Meade
Meade 2016년 4월 20일
  1. The GUIDE program creates guis using both an *.m file (what you posted) and a *.fig file (you did not post). You'd need to upload both in order for anyone to recreate your error.
  2. Good news though, your issue seems simple: Check out the uiwait and uiresume commands. Call uiwait at the end of the Main Fcn, then uiresume in the pushbutton fcn

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by