wait until picture selection.

2 次查看(过去 30 天)
Hi people,
I have some gui program in matlab. I create some pictures. Then I want to do profile on the pictures. I created push button, say "Manual profile". I push this button and then I want to program to wait until I will select between some pictures I already created.
function pushbutton15_Callback(hObject, eventdata, handles) %(manual profile button)
% hObject handle to pushbutton15 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%? what should be here?
% Here I want to wait until I select some picture
Then my purpose is to get handle to the selected figure and pass it to the function of improfile. In that way I want to create the profile on selected picture.
Thank you very much.

采纳的回答

Jan
Jan 2022-3-10
编辑:Jan 2022-3-10
You could add a button "Select this" to all open figures:
function pushbutton15_Callback(hObject, eventdata, handles)
openFig = get(groot, 'Children');
hButton = gobjects(1, numel(openFig));
hFig = ancestor(hObject, 'Figure');
for k = 1:numel(openFig)
hButton(k) = uicontrol(openFig(k), 'Style', 'PushButton', ...
'String', 'Select', ...
'Callback', {@selectBtn_Callback, handles, hFig});
end
setappdata(hFig, 'SelectButton', hButton);
end
function selectBtn_Callback(hObject, eventdata, handles, hFig)
hSelectedFigure = ancestor(hObject, 'Figure');
hButton = getappdata(hFig, 'SelectButton');
delete(hButton);
setappdata(hFig, 'SelectButton', []);
... do with hSelectedFigure what you want now
end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Code Execution 的更多信息

产品


版本

R2016b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by