how to do coding on popup menu to display image
조회 수: 2 (최근 30일)
이전 댓글 표시
I have design a GUI, i have about maybe 10 image name to select in the popup menu what code should i use so that the image i select at the popup menu will be call out?
댓글 수: 0
답변 (1개)
Geoff Hayes
2015년 4월 23일
haha - you will need to access the String and Value properties of the popup menu to get the image name that has been selected. Your popup menu callback would looks something like
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu1
% get the cell array of strings
popUpData = get(hObject,'String');
% get the index of the current selection
popUpIndex = get(hObject,'Value');
% write out the selection name
fprintf('%s\n',popUpData{popUpIndex});
Try the above and see what happens!
댓글 수: 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!