フィルターのクリア

Close prompt dialog box after hitting OK

4 ビュー (過去 30 日間)
monkey_matlab
monkey_matlab 2016 年 4 月 21 日
回答済み: Geoff Hayes 2016 年 4 月 24 日
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 Center および File Exchange2-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