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

采纳的回答

Geoff Hayes
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 个)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by