필터 지우기
필터 지우기

Managing several GUIs through a script

조회 수: 3 (최근 30일)
Avi Michaely
Avi Michaely 2018년 11월 5일
댓글: Walter Roberson 2018년 11월 6일
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?

채택된 답변

Stephen23
Stephen23 2018년 11월 6일
"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
Walter Roberson
Walter Roberson 2018년 11월 6일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by