Je voudrais juste savoir s'il serait possible de boucler efficacement les fonctions de l'interface graphique.Fonctions de l'interface graphique en boucle
function Menu1_CreateFcn(hObject, ~, ~) % --- Executes during object creation, after setting all properties.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white'); % Set the background color to white
end
function Menu2_CreateFcn(hObject, ~, ~) % --- Executes during object creation, after setting all properties.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white'); % Set the background color to white
end
function Menu3_CreateFcn(hObject, ~, ~) % --- Executes during object creation, after setting all properties.
% if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white'); % Set the background color to white
end
function Menu4_CreateFcn(hObject, ~, ~) % --- Executes during object creation, after setting all properties.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white'); % Set the background color to white
end
Au moment j'ai:
HandleNames = {'Menu1','Menu2','Menu3','Menu4'};
for d = 1:4
eval('function (HandleNames{d})_Callback(~, ~, ~)');
eval('function (HandleNames{d})_CreateFcn(hObject, ~, ~)');
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white'); % Set the background color to white
end
end
Mais je suis bien conscient que la fonction eval est pas une bonne pratique et il jette quelques erreurs dans la fenêtre de commande, mais fonctionne toujours comme avant. Y aurait-il une façon plus élégante de le faire ou est-ce juste une chose que je dois traiter, Cheers.