How to Use Edit Text in GUI in creating a filename?

조회 수: 6 (최근 30일)
John Hubert
John Hubert 2014년 2월 25일
댓글: Image Analyst 2014년 2월 25일
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!

답변 (2개)

Dishant Arora
Dishant Arora 2014년 2월 25일
function edit1_callback(hObject, eventdata, handles)
fileName = get(hObject, 'string');
setappdata(0, 'name', fileName);
f = getappdata(0, 'name');
  댓글 수: 11
Dishant Arora
Dishant Arora 2014년 2월 25일
편집: Dishant Arora 2014년 2월 25일
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
Image Analyst 2014년 2월 25일
I don't know why you're asking the user there. Why not just use uiputfile()?

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


Image Analyst
Image Analyst 2014년 2월 25일
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);

카테고리

Help CenterFile Exchange에서 Desktop에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by