우리는 데이터를 정렬하기 위해 여러 개의 풀다운이있는 프로그램을 작성하고 있습니다. 알맞은 크기의 데이터 세트이고 풀다운은 동적으로 생성됩니다. 결과적으로 풀다운을 변경할 때 다음 풀다운을 선택하기 전에 두 번째 또는 다섯 번째를 기다려야합니다. 그렇지 않으면 전체를 뒤집어 놓습니다. 그래서 모든 UI 요소를 비활성화하는 작은 함수를 작성했습니다 (속성을 해제 할 수 있도록 설정).Matlab gui 항목 비활성화하기
문제는 풀다운 콜백 함수에서 안정적으로 작동하지 않는다는 것입니다.
function deactivate_pulldowns(handles)
set(handles.first_data_field_pulldown,'enable','off');
set(handles.first_key_data_list_pulldown,'enable','off');
set(handles.second_data_field_pulldown,'enable','off');
function first_data_field_pulldown_Callback(hObject, eventdata, handles)
%deactivate the pulldowns until processing is complete
deactivate_pulldowns(handles);
%wipe out the old pull down if it exists
try
[dummy, dummy] = size(handles.first_field_reduced_key_data);
handles.first_field_reduced_key_data = '';
clear handles.first_field_reduced_key_data
catch
% ... This is pretty long and does a bunch of processing and takes time
따라서 위의 사항은 작동하지 않습니다. 그러나 deactivate_pulldowns 호출 바로 뒤에 메시지 상자를 추가하면 제대로 작동합니다.
function first_data_field_pulldown_Callback(hObject, eventdata, handles)
%deactivate the pulldowns until processing is complete
deactivate_pulldowns(handles);
msgbox('test1');
%wipe out the old pull down if it exists
try
[dummy, dummy] = size(handles.first_field_reduced_key_data);
handles.first_field_reduced_key_data = '';
clear handles.first_field_reduced_key_data
catch
% ... This is pretty long and does a bunch of processing and takes time
이렇게하면 예상대로 모든 풀다운이 비활성화됩니다. 여기서 뭐하는거야!?
uicontrol이 사용 중지 된 것처럼 보이지 않을 수도 있지만 아마도 시각적 모양 만 업데이트되지 않습니다. 처리 중에 클릭 해 보았습니까? 'msgbox'를 추가하는 것은 @chappjc 대답과 동일한 효과를가집니다. 즉, 변경된 GUI 요소를 다시 칠할 수 있습니다. – sebastian
클릭 할 수있었습니다. 그러나 실제로 그것이 무엇인지는 잘 모르겠습니다. chappjc의 대답은 내가 필요로했던 것과 정확히 일치했다. –
음, 분명히 항상 클릭 할 수 있습니다 - 문제가 발생하면 당연히 ... – sebastian