0
我正在嘗試使用GUIDE構成的GUI填充彈出式菜單。我做如下:使用目錄文件填充彈出式菜單
TestFiles = dir([pwd '/test/*.txt']);
TestList = [];
for i = 1:length(TestFiles)
filename = TestFiles(i).name;
TestList = [TestList filename];
end
set(handles.popup_test,'string',TestList);
我這樣做的popup_test_CreateFcn
方法中(我真的不知道這是雖然正確的地方)。
當嘗試啓動我不斷收到這樣的GUI:
??? Attempt to reference field of non-structure array.
Error in ==> init>popup_test_CreateFcn at 101
set(handles.popup_test,'string',TestList);
Error in ==> gui_mainfcn at 96
feval(varargin{:});
Error in ==> init at 19
gui_mainfcn(gui_State, varargin{:});
Error in ==> @(hObject,eventdata)init('popup_test_CreateFcn',hObject,eventdata,guidata(hObject))
??? Error using ==> struct2handle
Error while evaluating uicontrol CreateFcn
所以,出於某種原因,set()
方法不是讓我來填充TestList彈出菜單。
有什麼想法?
在此先感謝。
非常感謝,我被現在擺脫了錯誤的最小。事情是當我現在運行它時,彈出菜單是空的。我有這樣的感覺,它與迭代填充TestList的位置有關,我是否正確地將它移動到'XXXX_OpeningFcn(hObject,eventdata,handles,varargin)'? –
嘗試'set(handles.popup_test,'string',['a';'b';'c']);'如果它有效,因此如果您在'popup菜單'中看到'abc',那麼你知道你的文件存在問題。 – Maroun
沒關係,我的壞。我解決了它,非常感謝! :) –