How to Use Edit Text in GUI in creating a filename?
2 views (last 30 days)
Show older comments

Hi Guys. My main problem is how to create a filename through editText in GUI? kindly take a look on the picture. :") I just want to know on how to enter a name in "EditText" in GUI and that entered text will be the name/value for the variable 'f'. Thank you!
0 Comments
Answers (2)
Dishant Arora
on 25 Feb 2014
function edit1_callback(hObject, eventdata, handles)
fileName = get(hObject, 'string');
setappdata(0, 'name', fileName);
f = getappdata(0, 'name');
11 Comments
Dishant Arora
on 25 Feb 2014
Edited: Dishant Arora
on 25 Feb 2014
Great!! works perfectly fine for me. Make sure you press correct push button. See what your error code says and let us know if it needs a spell check. This is so ignorant
Image Analyst
on 25 Feb 2014
I don't know why you're asking the user there. Why not just use uiputfile()?
Image Analyst
on 25 Feb 2014
John, all of this would probably be best done in gui.m rather than a separate file. If you're going to have your GUI_OpeningFcn() call initilializer.m then you should get rid of the clear and have it be a function where you pass in handles so that initializer.m will have access to all the GUI controls.
Then, don't call input() if the user is supposed to type something into the edit field. You just, at the appropriate time (which means after the user has typed something in), get the value with
filename = get(handles.edit1, 'String');
Or else you do ask for it with input(), or better yet inputdlg(), and then use set to send what they typed in to the edit field
userString = inputdlg(..... whatever....
% Stuff into edit field.
set(handles.edit1, 'String', userString);
0 Comments
See Also
Categories
Find more on Desktop in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!