Hot to set fields from one GUI to another
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Più risposte (3)
Jan
il 21 Gen 2014
Modificato: Jan
il 21 Gen 2014
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 Commenti
Vedere anche
Categorie
Scopri di più su Loops and Conditional Statements in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!