GUI toolbar frozen by uiwait command
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Geoff Hayes
el 2 de Dic. de 2016
Rachel - please provide a sample of your code that exhibits the problem so that we can better troubleshoot it.
Respuestas (3)
Image Analyst
el 2 de Dic. de 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 comentarios
Image Analyst
el 5 de Dic. de 2016
Editada: Image Analyst
el 5 de Dic. de 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
el 25 de Jul. de 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 comentarios
Felipe Lima
el 5 de En. de 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
el 31 de En. de 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 comentarios
Ver también
Categorías
Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!