GUI toolbar frozen by uiwait command
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I created a GUI in Guide that includes axes and a toolbar to zoom and pan. I added uiwait to OpeningFcn and uiresume on a button callback, to allow user input prior to returning the output to a script from the OutputFcn. But now the toolbar no longer works. I need the toolbar function before the ouput is returned. How can I get the toolbar to work?
2 Kommentare
Geoff Hayes
am 2 Dez. 2016
Rachel - please provide a sample of your code that exhibits the problem so that we can better troubleshoot it.
Antworten (3)
Image Analyst
am 2 Dez. 2016
I don't have uiwait in my GUIs. I can have my script wait for the GUIDE-based GUI and I still have access to the tool ribbon if I switch back to MATLAB. For example with my threshold GUI:
grayImage = imread('moon.tif');
imshow(grayImage, []);
[lowThreshold, highThreshold] = threshold(83, 255, grayImage); % Wait for user input before continuing.
fprintf('done');
Try taking out the uiwait().
2 Kommentare
Image Analyst
am 5 Dez. 2016
Bearbeitet: Image Analyst
am 5 Dez. 2016
Are you saying that your main GUI keeps on executing code beyond the call to your second GUI and doesn't wait for you to close the second GUI? Because mine do not. Maybe try making your second GUI modal, but I don't think that should not be necessary.
Simon Morisset
am 25 Jul. 2017
Hello I have the same problem (Matlab 2015b). If I add "uiwait(handles.figure1);" at the end of the function *OpeningFcn(hObject, eventdata, handles, varargin) I can't any more use the zoom toolbar. The figure is like freeze...
2 Kommentare
Felipe Lima
am 5 Jan. 2021
Rachel
what did you mean by: "Add the line 'Zoom On' to the function". Can you show an example ? I have the same problem...
Daniel Rivera
am 31 Jan. 2023
A bit late, but I found that instead of using uiwait(), putting in a while loop waiting for a UserData parameter to change works as well. In the opening function, I set the userdata to true.
function myGUI_OpeningFcn(hObject,eventdata,handles,varargin)
...
hObject.UserData = true;
...
end
The output function tries to run immediately so I force it into a while loop until the userdata is set to false by another function, such as the CloseRequestFcn. Since the function started, you'll need to call for the handles to be updated (which I can't figure out right now) or use the getappdata/setappdata on the data you wish to pull.
function varargout = myGUI_OutputFcn(hObject,eventdata,handles)
while hObject.UserData
drawnow
end
% get desired outputs using getappdata
varargout{1} = getappdata(hObject,'VarName');
...
end
function myfigure_CloseRequestFcn(hObject,eventdata,handles)
var = handles.myOutputName % get stored handles variable
setappdata(hObject,'VarName',var) % store variable information for access by the output function
hObject.UserData = false;
end
0 Kommentare
Siehe auch
Kategorien
Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!