Diplay wav files in listbox GUI

조회 수: 2 (최근 30일)
arina octave
arina octave 2016년 5월 31일
댓글: arina octave 2016년 6월 10일
Hi, I need to make a listbox GUI that displays every wav files that I have in a folder. What I want is I just simply put the cursor in one of the wav files at the listbox and click a pushbutton to run my sound processing code. I have this function :
function wavlist_Callback(hObject, eventdata, handles)
function wavlist_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function tab1button_Callback(hObject, eventdata, handles)
Like this :
I've tried to put this code in my GUI code but I don't really know how to make it right :
allfiles = dir; %get files
allname = {allfiles(~[allfiles.isdir]).name}
Someone please help me...

채택된 답변

Walter Roberson
Walter Roberson 2016년 5월 31일
set(handles.wavlist, 'String', allname);
and inside wavelist_Callback
wavnames = get(hObject, 'String');
choice = get(hObject, 'Value');
selected_file = wavnames{choice};
  댓글 수: 9
Walter Roberson
Walter Roberson 2016년 6월 10일
Make sure you do not press the pushbutton before you have used the listbox to select an item. Or, alternately, make sure that you define handles.selected_file even before the listbox callback has ever been run.
arina octave
arina octave 2016년 6월 10일
argh my bad, thank you so much Walter. you've been a great help!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by