Managing several GUIs through a script
1 view (last 30 days)
Show older comments
Hello. So I have a few GUIs I have created, and I want to control all of them through one "main.m" script. Which means, passing data from all GUIs to main.m, and from main.m to a GUI. I'm sure it's possible, but how can it be done? I'm pretty sure I can do it with global variables but I'm trying to avoid using them, is there another way?
0 Comments
Accepted Answer
Stephen23
on 6 Nov 2018
"I'm pretty sure I can do it with global variables but I'm trying to avoid using them"
Avoiding global variables is a good idea.
"...is there another way?"
1 Comment
Walter Roberson
on 6 Nov 2018
A word of caution: if you use a gui modelled on guide, then the handles structure you receive for any callback is likely to reflect information attached to the figure whose child the graphics object is. In order to refer to a handles structure held by another figure, you need a handle to something in that figure.
- You can adopt the tactic that the master gui passes its own handle to each other gui it starts.
- you can adopt the strategy of having a unique Tag for the master gui and have other guis findobj to find the figure handle
- you can adopt the strategy of attaching unique userdata to the master figure and use findobj to locate it
- watch out for Handle Visibility issues: you might need to findall instead of findobj
- you might be able to get the children of the root object and poke through the list to find the master gui
- shared variables can be useful, but requires lexical scoping which is often not practical for larger code bases
- you could adopt the tactic that when a gui is first invoked that it evaluates something in the context of of its caller in order to locate the master gui and saves that information in its own local information
- you could adopt the tactic of using gco or gcbo or gcbf when a gui is first invoked in order to find information about the master gui and stores that information locally. Watch out for multiple levels of gui.
More Answers (0)
See Also
Categories
Find more on Migrate GUIDE Apps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!