Borrar filtros
Borrar filtros

calling a function in one GUi from another

3 visualizaciones (últimos 30 días)
Matthew O'Brien
Matthew O'Brien el 23 de Sept. de 2011
Hi,
Im trying to learn how to make some GUIs share data. I have read some of the documentation and have some idea on for example taking and displaying the text stored in one GUI handle in the text box of another when a button in the second is pressed, but what i want to do is simply pass and display some data from one GUI to another without restarting it and without doing anything in the second GUI (i suppose you could say i want to 'push' the information rather than 'pull it?)', For example:
GUI1 contains a edittext1 and a pushbutton1 GUI2 just contains edittext1
When GUI1:pushbutton1 is pressed I want GUI2:edittext1 to display GUI1:edittext1
I know that using something like:
GUI2('GUI1', handles.figure);
can be used to initialise GUI2 however i dont want to initialise the GUI every time i pass the the value between the two. i.e. i want to make GUI1 activate a function in GUI2 which just displays the edittext value.
I know this is a simple question but a simple example would be great to help me!
Many thanks
Matt

Respuesta aceptada

Jan
Jan el 23 de Sept. de 2011
You need a method to let GUI1 find the handle of GUI2. E.g. the 'Tag' of the FIGURE might be helpful. Then the callback of the GUI1:pushbutton1 searches this tag at first:
GUI1H = findobj(allchild(0), '-flat', 'Tag', 'GUI1');
Now you can get the handles STRUCT of GUI1:
GUI1_handles = guidata(GUI1H);
Assuming, that you find the handle of the edittext1 there:
GUI2_handles = guidata(ObjH); % Handles of GUI1
set(GUI2_handles.edittext1, ...
'String', get(GUI2_handles.edittext1));
  1 comentario
Matthew O'Brien
Matthew O'Brien el 23 de Sept. de 2011
Hi Jan,
Thanks for the answer! It works but apparently -flat is an invalid option in r2008b but it works without that option.
I will continue in my endeavour to make GUIs work together!
Thanks

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Text Data Preparation en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by