Thread Subject: Passing variables between gui?

Subject: Passing variables between gui?

From: petros dias

Date: 30 Jun, 2009 11:31:01

Message: 1 of 2

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!

Subject: Passing variables between gui?

From: Thierry LE GALL

Date: 7 Jul, 2009 12:42:02

Message: 2 of 2

"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

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
handles petros dias 30 Jun, 2009 07:34:02
gui petros dias 30 Jun, 2009 07:34:02
exchange data petros dias 30 Jun, 2009 07:34:02
rssFeed for this Thread

Contact us at files@mathworks.com