How to call pop-up-menu call back in Pushbutton???

2 visualizaciones (últimos 30 días)
Ali Ahmed
Ali Ahmed el 13 de Mayo de 2013
Hi I'm making my Gui to classify images. For this purpose i'm using two methods Neural network (NN) and kth nearest neighborhood (KNN) method for that i used popupmenu to select one of the method.. But problem is that i'm forming handles field in opening function. By using these fields I initially display image using popupmenu. If I select Knn method it display Knn image But Problem is that when I select NN method it donot display NN image but I want to display it. The opening function code and popup menu code is given as if true function sabih_expression_OpeningFcn(hObject, eventdata, handles, varargin)% code O5=imread('k-nn.png'); handles.KNN=O5; handles.main=handles.KNN; O6=imread('nn.png'); handles.NN=O6; handles.nnet=handles.NN; handles.output = hObject; guidata(hObject, handles); end
and pop up menu code is
if true
function method_popup_Callback(hObject, eventdata, handles) % code
% hObject handle to method_popup (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 method_popup contents as cell array
% contents{get(hObject,'Value')} returns selected item from method_popup
val=get(hObject,'Value');
str=get(hObject,'String');
switch str{val};
case 'KNN'
handles.main=handles.KNN;
a=handles.main;
imshow(a,'parent',handles.axes4);
case 'NN'
handles.nnet=handles.NN;
b=handles.nnet;
imshow(b,'parent',handles.axes4);
end guidata(hObject, handles); % code end
it displays image when I select Knn but donot display image when I select NN.
2ndly how can I use call back of popupmenu in pushbutton.. (As im new gui programmer)
I have two pushbuttons When execute knn data and other execute NN data. I want to use button such that when I select knn in popup menu then only Knn pushbutton works if NN pushbutton is pushed when knn is selected it displays warning...
Thanks If someone help me out I shall be very thankful.....
Regards
Ali Ahmed
  2 comentarios
Jan
Jan el 13 de Mayo de 2013
Please lern how to format code in the forum properly.
Ali Ahmed
Ali Ahmed el 13 de Mayo de 2013
yup I'll try my level best.

Iniciar sesión para comentar.

Respuesta aceptada

Yao Li
Yao Li el 13 de Mayo de 2013
Try remove the selections codes from the opening function to other callback functions And try
get(handles.method_popup, 'Value');
to get the current selection of the popupmenu
  3 comentarios
Yao Li
Yao Li el 14 de Mayo de 2013
I guess that is because you call the popupmenu callbacks in the opening function which is effective only when you open the GUI. Thus, try to remove the selection codes to other callbacks, such as popupmenu_CreateFcn. I'm not sure about that since I can't see all your functions here.
Ali Ahmed
Ali Ahmed el 15 de Mayo de 2013
Thanks Yao Li i'm trying what you suggest and I found me very helpful Thanks once again..

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by