wait until picture selection.

3 Ansichten (letzte 30 Tage)
Dimani4
Dimani4 am 10 Mär. 2022
Kommentiert: Dimani4 am 12 Mär. 2022
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.

Akzeptierte Antwort

Jan
Jan am 10 Mär. 2022
Bearbeitet: Jan am 10 Mär. 2022
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
  1 Kommentar
Dimani4
Dimani4 am 12 Mär. 2022
Thank you very much!!!!! Great solution!!!!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange

Produkte


Version

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by