Close prompt dialog box after hitting OK
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
monkey_matlab
il 21 Apr 2016
Risposto: Geoff Hayes
il 24 Apr 2016
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 Commenti
Risposta accettata
Geoff Hayes
il 24 Apr 2016
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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Graphics Object Programming in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!