0
GUI 기능을 효율적으로 루핑 할 수 있는지 알고 싶습니다.루핑 GUI 기능
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
하지만 난 eval 함수는 좋은 방법이 아니고, 명령 창에서 일부 오류를 던지고 있지만 여전히 이전처럼 작동하고 있는지 잘 알고 : 순간
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
나는 있습니다. 이것을 할 수있는보다 우아한 방법이있을 것인가, 아니면 내가 다뤄야 만하는 것인가, 환호.