Is there a workaround to use GUIs created with GUIDE inside a namespace?

조회 수: 3 (최근 30일)
Duijnhouwer
Duijnhouwer 2018년 10월 9일
답변: Saurabh 2024년 12월 17일
I run into the problem GUIs created with GUIDE cannot be placed inside a namespace.
For example, i have a namespace folder +ns which contains gui.fig and the corresponding gui.m.
Now, when I run
>> +ns.gui
It fails because this command starts +ns.gui.m which then searches for gui.fig which it can't find because it's hidden in the namespace...
Has anyone figured out a way around this? Is there an edit we can make to the boilerplate code that GUIDE creates so that it looks in the same namespace that the gui.m is in?
Thanks in advance.
Jacob
I pasted the full error below, mostly to facilitate finding this problem.
>> +ns.gui
Error using load
Unable to read file 'gui.fig'. No such file or directory.
Error in matlab.graphics.internal.figfile.FigFile/read (line 31)
hgDataVars = load(filename, '-mat', '-regexp', '^hg[M]');
Error in matlab.graphics.internal.figfile.FigFile
Error in hgload (line 54)
FF = matlab.graphics.internal.figfile.FigFile(filename);
Error in matlab.hg.internal.openfigLegacy (line 57)
[fig, savedvisible] = hgload(filename, struct('Visible','off'));
Error in gui_mainfcn>local_openfig (line 286)
gui_hFigure = matlab.hg.internal.openfigLegacy(name, singleton, visible);
Error in gui_mainfcn (line 158)
gui_hFigure = local_openfig(gui_State.gui_Name, gui_SingletonOpt, gui_Visible);
Error in ns.gui (line 40)
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
  댓글 수: 1
Qitr
Qitr 2024년 12월 15일
Have you managed to deal with that problem?
Recently, I have been trying to resurrect old application made in Guide and I have obtained the same problem.

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

답변 (1개)

Saurabh
Saurabh 2024년 12월 17일
Hi @Qitr,
Try the following workaround and check if this solves the issue:
Open the GUI in 'GUIDE', and exploit one of the 'GUIDE's' features by exporting the entire GUI to a single M-file. This can be done through 'GUIDE's' menu bar: "File-->Export...", Then make sure that the object's method calls the new single M-file.
Alternatively, another way to workaround the problem is by putting the GUI's M and FIG-files on the MATLAB path outisde of the class directory.
I hope this helps.

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by