Close prompt dialog box after hitting OK
조회 수: 4 (최근 30일)
이전 댓글 표시
Hello,
In the function below, I wanted to be able to close the prompt window after hitting the OK button. However, with the code, the window still remains open. Please help me close the prompt window after hitting OK. Thanks.
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);
uiwait
function varargout = prompt11_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
function pushbutton1_Callback(hObject, eventdata, handles)
uiresume
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
closereq
댓글 수: 0
채택된 답변
Geoff Hayes
2016년 4월 24일
monkey_matlab - try removing the uiwait and uiresume calls as I don't think that they are needed in this case.
The closereq is unexpected in the edit1_CreateFcn. Doesn't this generate an error message when you try to run your code? If you want to close the GUI when the user presses the OK button, then I would put this command into the pushbutton1_Callback or do
function pushbutton1_Callback(hObject, eventdata, handles)
close(handles.figure1);
assuming that figure1 is the name of your figure/GUI.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Object Programming에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!