Pushbutton callback not working
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ali
el 3 de Oct. de 2022
Comentada: Ali
el 3 de Oct. de 2022
I am working on a gui which is composed of 2 listbox and 2 pushbutton ok and cancel. The first part of my programe calculate the items that will go in the listboxes. The next part allow the user when he press on ok to get the number of the selected elements in each listbox and return it in an excel file. I put an exemple of what it is supposed to do (exemple is the gui and exemple 2 is the function that run it)
My exemples work great but the actual program when it comes to the part with the switch (all the above works fine) :
function res=kgexec4e(cn,OptPref)
%kgexec4e Création de la boite de dialogue "Choix Export" associée à
%kgexec4
% Detailed explanation goes here
persistent res1 Varlist1 Varlist2%[] Initialement
%Appel du menu
h0 = kgui4e
%Calcul contenue listbox barre
Varlist1 = cn.Barres.Nom(1:end);
if OptPref.CacheBarr
Varlist1=Varlist1(~strncmp(Varlist1,'@',1)); %suppression des noms auto en fonction du menu Pref
end
%Calcul contenue listbox Element
Varlist2 = cn.Elements.Nom(1:end);
if OptPref.CacheElem
Varlist2=Varlist2(~strncmp(Varlist2,'@',1)); %suppression des noms auto en fonction du menu Pref
end
%%%Mise à jour contenu des listboxs
set(findobj(h0,'Tag','Barres'),'String',Varlist1)
set(findobj(h0,'Tag','ELement'),'String',Varlist2)
res = res1
switch get(h0,'Tag')
case 'OptOK'
nb = get(findobj(h0,'Tag','Barres'),'Value')
ne = get(findobj(h0,'Tag','ELement'),'Value')
end
end
it always gives me this error which i don't understand as the part of this programe that is slightly different from the exemple works but the similar part won't work.
here is the error message : (kguie is the gui which is the exact same as exemple gui)
Error in Caviar\private\kgui4e (line 5)
gris=[0.75 0.75 0.75];
Output argument "h0" (and maybe others) not assigned
during call to
"C:\Users\223080038\Documents\m\CAVIAR3.1.2
_m_original\R2012a\Caviar\private\kgui4e.m>kgui4e".
Error in kgexec4e (line 8)
h0 = kgui4e
Error while evaluating uicontrol Callback
4 comentarios
Cris LaPierre
el 3 de Oct. de 2022
Editada: Cris LaPierre
el 3 de Oct. de 2022
I think there is some confusion caused by how you have chosen to name your files. My understanding is that example.m is the main file, and the one to run to launch the gui. Clicking the OK button runs the callback function, which is example2.m. This will populate the two listboxes in the gui with numbers. Is that correct?
That is the workflow I followed and did not get any errors. I selected the current folder when the popup appeared. When I select a number from either listbox, an xlsx file is added to the folder I'd selected in the popup and the app closes (file attached). The file appears to always be the same, no matter what number or listbox I select.
I am noticing line numbers in the files you have shared do not align with line numbers in the error message you pasted.
Respuesta aceptada
Más respuestas (0)
Ver también
Categorías
Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!