How can I properly communicate and edit real-time with master and child structs using GUIDE?

Hey, first time poster! This site is very useful for asking questions. I'm doing an assignment for my engineering class (we get to figure out a lot of stuff on our own) and I have been experimenting. Currently, I have a master GUI or parent GUI that has 4 "kids". These kids modify values in the parent struct as well however I am not sure how to properly modify these values. Only one GUI is visible at a time, however.
Originally I thought simply calling the parent and kids by using:
WEIGHTSANDBALANCE('CALLBACK',hObject,eventData,handles,...)
, things like that. However, this always brought the Singleton to the front even when Visibility was set to off.
I decided that the next best thing to do was to have the parent simply have child structs inside the structure itself. This means to modify children it'd be something around
set(handles.WeightsAndBalanceHandles.text,'String','Testing stuff, man')
This works perfectly however the child cannot talk to the parent because it causes a recursion issue and MATLAB yells at me. Is there any way around this? Perhaps there's some way to do this properly that I don't understand? Thanks

7 Comments

GUIDE is not designed to be able to support multiple GUI.
I cannot do anything to change that. This is a project given by my school's First Year Engineering course and we have to use multiple GUIs in order to do this project and they must be able to communicate to each other in some way to update or change data. How do I update the handles properly in another GUI since that seems to be the big issue. If I am to ever add a handle to the weightsAndBalance structure it is not kept there. I've been trying another method to have the Summary page be the child to other pages since that may help but I have been unsuccessful there too. The method my TAs have recommended me is calling the GUI and giving it handles then using try and catch to setup variables.. which I find a horrible method.
Basically. The whole semester we have been taught GUIDE and how to use this. Plus, it is a group project and the whole group is meant to understand how the GUI was built. Is there a possibly-easier-to-understand method? All that really needs to be done is variable modifying in other GUIDEs without raising the existing one since 'raising' it also brings it on screen (even if I were to put it off-screen). Edit: I want to add that the TAs must understand it too and their knowledge of MATLAB doesn't exceed much beyond my own.
One way I can think of is to make both parent and child structs global, which can be achieved by using setappdata(0,...) to have them stored as appdata on root.
If I were to use getappdata(0,...) and modify it then resave would it change the handles in the GUI I used with it originally? For example, if I did setappdata(0,'GUIA',handles) and in GUI B I did x = getappdata(0,'GUIA'), modify it then set it again as setappdata(0,'GUIA',x) would GUIA reflect those changes? Forgive my newness :)
Yes, GUIA is the name for handles in your case, once you change the value for GUIA, it'll reflect changes.

Answers (1)

I'm not quite sure what you want. But can your problem be fixed if some variables are saved to the 'base' workspace? If it works, use assignin() to assign the variables to the workspace and use evalin() to import the varaibles from workspace to the callbacks

3 Comments

I would have to update the code every time a GUIDE is brought to the front. It could work, I suppose. Is there no way way to have GUI A modify GUI B's handle to display a certain string?
I remembered there was someone solved a similar problem last week, but I can't find it now.

This question is closed.

Products

Asked:

on 14 Apr 2013

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!