uipanels list box problems

sir,can I know why the list of images cannot be listing in my gui after built the coding?here is the code
window=figure( 'Units', 'pixel' ,...
'Position', [320,180,650,500] ,...
'Resize', 'on' ,...
'Color', [.7,.7,.7] ,...
'NumberTitle', 'off' ,...
'MenuBar', 'none' ,...
'Name', 'Pre-Processing Process');
headpanel = uipanel('Parent',window,'FontSize',15,...
'Title','Main', 'TitlePosition','lefttop',...
'BackgroundColor',[.8,.8,.8] ,...
'FontWeight','bold',...
'Position',[.22 0.14 .45 .65]);
leftpanel=uipanel('Parent',window,'BackgroundColor',[.8,.8,.8],...
'Position',[.04 .29 .15 .5]);
axes1= axes( 'Parent',headpanel,...
'Units','normalized', ...
'Position',[0.01 0.01 2 2]);
set(axes1, ...
'Visible', 'on', ...
'Units', 'pixels');
sButton = uicontrol(window,'String','Select Image Folder',...
'CallBack', 'folder=uigetdir(''C:\Users\s'',''Select Image Folder'');',...
'Position',[55 620 190 25]);
'if folder ~= 0,';...
% Assign the value if they didn't click cancel.
'handles.ImageFolder = folder;';...
'handles = LoadImageList(handles)';...
'guidata(hObject, handles)';...
'else';...
'msgbox(''No folder specified as input for function LoadImageList.'', ''select folder'',''modal'');';...
'end,';...
hDeplb = uicontrol(leftpanel,'Style','listbox','Units','normalized',...
'String',{'Select Image'},...
'Position',[.01 .0 1 1],'BackgroundColor','white','FontSize',9);
'varargout{1} = handles.output;';...
'handles.output= hObject;';...
'guidata(hObject, handles);';...
ListOfImageNames = {};
' folder = handles.ImageFolder';...
'if ~isempty(handles.ImageFolder) ';...
'if exist(folder,''dir'') == false';...
'msgbox([''Folder '' folder does not exist.''])';...
'end';
' else';
'msgbox(''No folder specified as input for function LoadImageList.'');';...
'end';

답변 (1개)

Image Analyst
Image Analyst 2012년 8월 25일

1 개 추천

Probably because the syntax is just so totally mangled. You should really read the Getting started section of the help. You don't need to use ... at the end of every line. You only need to use it if you have a really long line of code - a single line of code - that you want to split over 2 or more lines for readability purposes. Second, your code looks like some kind of weird hybrid of GUIDE (because I can see the "handles" structure" and creating your own controls via code (uipanel, uicontrol, etc.) Plus a huge portion of the lines of code are enclosed within apostrophes for some unknown reason. Who told you to do that? I don't know what else to say except that you need to clean it up a lot. Watch Doug Hull's video tutorials - that might help.

댓글 수: 17

Matt Fig
Matt Fig 2012년 8월 25일
I wonder if those are supposed to be callback strings?! But then why is there a varargout?? Confused....
I second IA's recommendation to go back to basics and read up on the documentation on GUI making.
Tulips
Tulips 2012년 8월 31일
can I know how to design GUI using uipanels?especially when there is involve with callback pr create function.how to assign in m-file?
Image Analyst
Image Analyst 2012년 8월 31일
Have you watched Doug Hull's videos on his blog?
Robert Cumming
Robert Cumming 2012년 8월 31일
or download Matts 41 GUI examples from FEX
Tulips
Tulips 2012년 9월 15일
hi,i'd learned the GUI example from the link u gave above.but can someone explain to me how to listing a sort of images file in listbox panels?can we put a callback function to call 2 function simultaneously?how can i do that.! one more thing, how to assign hobject and handles in uipanels in matlab!
per isakson
per isakson 2012년 9월 15일
Maybe you should update the code in your question. I guess it is obsolete.
Have you tried sort()? Get the 'string' property of the listbox. Then call sort, then set the string property to send the sorted list back into the listbox. Something like (untested):
set(handles.listbox1, 'String', sort(get(handles.listbox1, 'String')));
Tulips
Tulips 2012년 9월 15일
How can I know make a list of images file in listbox from a directory.When I click a button 'select from directory' it will go to a directory and listing a sort of iamges in a listbox..?how can I do that.I used uipanel to develop gui.
Walter Roberson
Walter Roberson 2012년 9월 15일
uigetdir() to allow the user to select the directory. dir() to get the contents of the directory. set() the String property of the listbox to the names of the files you found in the directory.
Tulips
Tulips 2012년 9월 16일
how to assign command in the bracket (). can you explained to me? no need to assign the callback function?
folder = uigetdir()
filenamesStructure = dir(folder)
baseFileNames = strvcat(filenamesStructure.name)
set(handleToListbox, 'String', baseFileNames);
Walter Roberson
Walter Roberson 2012년 9월 16일
You would usually assign the callback function at the time you create the listbox. Or are you talking about the callback for the button to 'select from directory' ?
Tulips
Tulips 2012년 9월 27일
the link u gave above is not easy to understand. if possible can u explain me the callback coding of matlab so that the button can 'select from directory' and display list of figure in list box!thanks in advance!
You don't need to understand what uipickfiles does internally, just use it. I simply did
selectedFile = uipickfiles()
and it worked fine.
Tulips
Tulips 2012년 10월 1일
편집: Tulips 2012년 10월 1일
how to put make a list of images(document) in uiPanels list box so that it can be selected easily.
Inside your function LoadImageList(handles), you need to do something like
selectedFiles = uipickfiles()
set(handles.listbox, 'String', selectedFiles);
Tulips
Tulips 2012년 10월 2일
have tried it up but it 'undefine function or variable uipickfiles' how to assign uipickfiles. get confused already..:(

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

질문:

2012년 8월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by