Hot to set fields from one GUI to another
조회 수: 2 (최근 30일)
이전 댓글 표시
Dear all,
I've been able to transfer variables from one gui to another, there's plenty of stuff around on that.
What I haven't been able to do is to set a field of a GUI from another GUI.
Here's an example: I have two GUIs opened: GUI1 and GUI2. GUI1 has a text box, GUI2 has a push button. Now, when I push the button on GUI2 I would like so set the string in the text box of GUI1 to something.
How can I achieve this?
Thanks!
Lorenzo
댓글 수: 0
채택된 답변
추가 답변 (3개)
Jan
2014년 1월 21일
편집: Jan
2014년 1월 21일
If you can provide variables from one GUI to the other, you can provide the handles struct also. And there you find the handles of the GUI objects. If your GUIs have the tags "GUI1" and "GUI2" (a bad choice, by the way), you can set the text of an object in GUI1 from a callback of GUI2:
function ButtonCallback(hObject, EventData, handles)
% Better do this once only!
gui1H = findobj(allchild(0), 'flat', 'tag', 'GUI1'); % [EDITED]
gui1Handles = guidata(gui1H);
set(gui1Handles.Button1, 'String', 'hello')
Add a TRY/CATCH for a meaningful error message, if the 2nd GUI has been closed before.
댓글 수: 2
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!