GUI varargout does not update
이전 댓글 표시
I've build a GUI that let users manually adjust a segmentation. However, varargout only 'captures' the first correction made. Any other corrections are not represented in my final output. My varargout function looks as follows:
function varargout = Clean_images_OutputFcn(hObject, ~, handles)
handles=guidata(hObject);
uiwait
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
varargout{1} = handles.MC_segmentation;
varargout{2}=handles.figure1;
uiresume
Furthermore, I have an callback and pushbutton to close the GUI.
% --- Executes on button press in Push_end.
function Push_end_Callback(hObject, eventdata, handles)
handles=guidata(hObject);
uiresume
varargout{1} = handles.MC_segmentation;
delete( handles.figure1)
How can I constantly keep updating my output?
댓글 수: 5
Geoff Hayes
2019년 2월 7일
Myrthe - does handles.MC_segmentation correspond to your first correction? How are you updating this in your code (to capture other corrections)?
Adam
2019년 2월 7일
Why do you have multiple
uiresume
instructions? After the first I imagine your OutputFcn is fired and then it won't be called again. You can easily check when it is called though just by having a breakpoint in.
If you didn't have a uiresume in your pushbutton callback then it would probably work for a 1-time return at the end, but if you want to keep returning multiple results as you get them from an open GUI then you can't do this via the OutputFcn as it will only be triggered once.
Rik
2019년 2월 7일
Outputs do not dynamically update in Matlab. You could probably design a class that does that. That might work like this: have a property in that class containing your segmentation, and then have a getter method that attempts an update by loading the guidata. If the update fails becose the GUI was closed you can return the previously loaded result, and otherwise you update your stored property as well.
Myrthe B.
2019년 2월 7일
Myrthe B.
2019년 2월 7일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!