Passing data between diferent GUIs
Show older comments
Hi,
I have a mainGUI and a constructorGUI, the first one exists to set the parameters for the secnd one, wich means i have to pass those parameters from multiple callbacks (on mainGUI) to the constructorGUI when I press a button.
On mainGUI I choose a puzzle to be done, collect all the data from that puzzle and its pieces, then i have to pass that data (coordinates of the pieces, locations of the files of every pieces, characteristics of the pieces,...) to the constructorGUI.
I was thinking to use setappdata and getappdata, I read a lot of information on that (setappdata on the mainGUI and getappdata on the constructorGUI) but I find myself trying to use that and getting all kinds of errors.
Can anyone explain me how to use this on TWO different GUIs and write a code example or if theres a better way to pass the data tell me about.
Thank you all!
Accepted Answer
More Answers (1)
Julien
on 6 Oct 2012
In fact, the first input for getappdata,setappdata, (and also set and get ) functions is a handle. It's a kind of pointer that contains the address (the ID) of a Matlab object.
The handle 0 correspond to the handle of the root.
If you define
fig=figure();
then, the variable fig will store the handle of the figure you have defined.
It's the same for each Matlab Object you create (figure,axes, uicontrols ...)
So, defining a structure that stores handles is a good way to share handles of all components you define.
In fact, GUIDE define by default a structure called handles which containes all handles of objects you have placed on the layout.
To acces a specific handle, type : handles.tag, which tag is the tag of the object you want to get handles.
insert somewhere in your GUI disp(handles) to see what the handles structure contains.
Categories
Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!