Managing several GUIs through a script

1 visualización (últimos 30 días)
Avi Michaely
Avi Michaely el 5 de Nov. de 2018
Comentada: Walter Roberson el 6 de Nov. de 2018
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?

Respuesta aceptada

Stephen23
Stephen23 el 6 de Nov. de 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 comentario
Walter Roberson
Walter Roberson el 6 de Nov. de 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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by