Dear sir, How can I link between two interface or three interface of GUI? to make it more friendly user.

5 vues (au cours des 30 derniers jours)
  1 commentaire
Geoff Hayes
Geoff Hayes le 15 Oct 2015
Are you trying to launch one GUI from the other? Or is each "interface" a frame within a single GUI?

Connectez-vous pour commenter.

Réponse acceptée

Dennie
Dennie le 16 Oct 2015
This actually quite a complex problem, with a very simple solution. I've encountered the same problem a couple of years ago and solved it with some basic tricks. I do not know if this is the best approach but it works.
So I will assume that you have used GUIDE to generate the matlab scripts for the GUI.
First step is to make the handle of your GUI accessible in the root memory of your PC. This is a number that matlab uses to find the GUI from a different one. use this code in the opening func of the GUI and remember the name you give to this appdata:
setappdata(0,'<GUI_a>',gcf) % 0 denotes root memory of pc, gcf = get current figure handle
then later on where you want to open GUI b you use the following code to do so:
handles.gui_b=gui_b; %name of the gui_b.m, this opens GUI B
handles.gui_b_struct=getappdata(handles.gui_b); % save the handle of gui_b in gui_a
handles.gui_b_data=handles.gui_b_struct.UsedByGUIData_m; %extract the handle to the handle structure of gui_b
Now GUI A is linked to GUI B. In GUI B now we need to connect to GUI A. We can do this by using the initial handle of GUI_A that we saved in the root memory. In the opening function of GUI B use this code:
handles.GUI_A=getappdata(0,'GUI_a'); % retrieve handle of GUI_A
handles.GUI_A_struct=getappdata(handles.GUI_A); % retrieve handle to the structure used in GUI_A
handles.GUI_A_data=handles.GUI_A_struct.UsedByGUIData_m; % retrieve data inside the structure in GUI_A
This code links the data saved in the structure in GUI A, so you can read and write data in that structure from GUI B.
Now if you call GUI C from GUI B you repeat this process, but you will also need to place the handle of GUI B in the root memory like you have done for GUI A to link GUI C. just add this code to the opening function of GUI B and repeat the steps of linking inside GUI C:
setappdata(0,'<GUI_b>',gcf)
I hope this helps,
Dennie
  4 commentaires
Dennie
Dennie le 19 Oct 2015
Exactly, you can close GUI A within the callback that opens GUI B. I'm not sure if you lose also the data inside the handle structure of GUI A if you close it like this. If this is the case, you can simply save the entire handle structure from GUI A to your harddisk using the save command and reload it when opening GUI A
Geoff Hayes
Geoff Hayes le 30 Mar 2016
Clément - please post your comment as a new question since that is what it is.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Historical Contests 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!

Translated by