GUI toolbar frozen by uiwait command
2 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
Geoff Hayes
2016 年 12 月 2 日
Rachel - please provide a sample of your code that exhibits the problem so that we can better troubleshoot it.
回答 (3 件)
Image Analyst
2016 年 12 月 2 日
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 件のコメント
Image Analyst
2016 年 12 月 5 日
編集済み: Image Analyst
2016 年 12 月 5 日
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
2017 年 7 月 25 日
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 件のコメント
Felipe Lima
2021 年 1 月 5 日
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
2023 年 1 月 31 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Migrate GUIDE Apps についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!