|
"petros dias" <p.dias@ucl.ac.uk> wrote in message <h2ct1l$gtb$1@fred.mathworks.com>...
> Hi all,
>
> I am building a small image processing suite, that contains a master GUI and sub GUIs' which you can call from the master GUI. The sub GUIs' generate some data which I want to pass back to the master GUI in my own variables (I don't want them stored in anything in the gui, rather than making my own, e.g. handles.custom). I am already using the handles structure to save these variables in the sub GUI and when I hit "Done" i want these variables to be passed to the main gui.
>
> I tried a small tutorial from here: http://blinkdagger.com/matlab/matlab-gui-how-to-easily-share-data-between-two-separate-guis but it doens't work for me. Any ideas? I know this far that I shouldn't use global variables for this so the handles structure is the way to go?
>
> Thank you!
Hi petros,
I had the same question to solve some years ago. Then I realized that the simplest way to proceed was to use global variables but using global structures to avoid data mismatch between the GUIs and to ensure code readability, maintenance and extensibility.
For example, considering 2 GUIs : GUI1 and GUI2, you would have to define one structure for each of them :
global t_gui1_param
global t_gui2_param
"t_" is just a convention to say that this is a structure (code readabiity).
Then, the exchange of information between the 2 GUIs would take the next formalism :
t_gui2_param.d_x = t_gui1_param.d_y
"d_" is just a convention to say that this is a data (code readabiity).
By coding convention, you should consider that only the GUI1 as allowed to write into t_gui1_param and same rule for the GUI2 with t_gui2_param. That would avo?d data mismatch and bugs.
I hope that this comment will be useful for you.
With Best Regards,
Thierry
|