Hot to set fields from one GUI to another
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Plus de réponses (3)
Jan
le 21 Jan 2014
Modifié(e) : Jan
le 21 Jan 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 commentaires
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!