Thread Subject: Removing menus installed by 3rd party toolkits

Subject: Removing menus installed by 3rd party toolkits

From: Francis Burton

Date: 30 Jul, 2009 10:31:47

Message: 1 of 12

I have a Guide-created GUI that I would like to compile to a stand-alone
app. That part seems to work fine. However, the problem is that when I
made the GUI it was "infected" by a non-Mathworks toolkit that installed a
menu in the .fig file (actually it installed 4 copies of the menu, I have
no idea why). Running the application gives errors thus:

??? Error using ==> struct2handle Undefined function or variable 'efmenu'.

??? Error using ==> struct2handle Error while evaluating figure CreateFcn

Apparently the menu(s) cannot easily be removed from the figure; at least,
the Object Browser doesn't offer the ability to delete objects.

So what is the simplest way to recreate the figure minus the offending
menus?

In GUIDE, I tried selecting all the controls, copy/pasting them into a
fresh window, and then replacing the generated .m file code with the
original code, but this gave a long list of errors because the controls'
tags were auto-generated ones rather than the more meaningful names I had
originally given them.

Does this mean that I have to go through all the 91 controls renaming them
one by one, before copying the original .m code over?

I thought I would ask here before embarking on this drudgery, in case
someone knew of a quicker way to do it.

Francis

Subject: Removing menus installed by 3rd party toolkits

From: us

Date: 30 Jul, 2009 10:53:02

Message: 2 of 12

Francis Burton <fburton@nyx.net> wrote in message <1248949901.946989@irys.nyx.net>...
> I have a Guide-created GUI that I would like to compile to a stand-alone
> app. That part seems to work fine. However, the problem is that when I
> made the GUI it was "infected" by a non-Mathworks toolkit that installed a
> menu in the .fig file (actually it installed 4 copies of the menu, I have
> no idea why). Running the application gives errors thus:
>
> ??? Error using ==> struct2handle Undefined function or variable 'efmenu'.
>
> ??? Error using ==> struct2handle Error while evaluating figure CreateFcn
>
> Apparently the menu(s) cannot easily be removed from the figure; at least,
> the Object Browser doesn't offer the ability to delete objects.
>
> So what is the simplest way to recreate the figure minus the offending
> menus?
>
> In GUIDE, I tried selecting all the controls, copy/pasting them into a
> fresh window, and then replacing the generated .m file code with the
> original code, but this gave a long list of errors because the controls'
> tags were auto-generated ones rather than the more meaningful names I had
> originally given them.
>
> Does this mean that I have to go through all the 91 controls renaming them
> one by one, before copying the original .m code over?
>
> I thought I would ask here before embarking on this drudgery, in case
> someone knew of a quicker way to do it.
>
> Francis

one of the very tedious solutions (r2009a)

     fnam='fig.fig'; % <- your fig name...
     v=load(fnam,'-mat');
     hgS_070000=v.hgS_070000; % <- may vary acc to your ML ver...
     c=hgS_070000.children; % <- the fig's children
     c.properties % <- see what they are/do...
% visually identify the bad children, eg,
     ix=[1,4];
     c(ix)=[]; % <- remove them
     hgS_070000.children=c; % <- save the good children...
     save('newfig.fig','hgS_070000');
     openfig('newfig.fig');

just a thought
us

Subject: Removing menus installed by 3rd party toolkits

From: fburton@nyx.net (Francis Burton)

Date: 30 Jul, 2009 17:21:13

Message: 3 of 12

In article <h4ru2e$842$1@fred.mathworks.com>, us <us@neurol.unizh.ch> wrote:
>one of the very tedious solutions (r2009a)
>
> fnam='fig.fig'; % <- your fig name...
> v=load(fnam,'-mat');
> hgS_070000=v.hgS_070000; % <- may vary acc to your ML ver...
> c=hgS_070000.children; % <- the fig's children
> c.properties % <- see what they are/do...
>% visually identify the bad children, eg,
> ix=[1,4];
> c(ix)=[]; % <- remove them
> hgS_070000.children=c; % <- save the good children...
> save('newfig.fig','hgS_070000');
> openfig('newfig.fig');
>
>just a thought
>us

Thanks, us. The last four elements of c.properties were

ans =

              Label: 'EzyFit'
    ApplicationData: [1x1 struct]
           Behavior: [1x1 struct]
            Visible: 'off'

and I deleted them and wrote the data back to the figure file as
instructed. However, when I opened it again I got the same message
as previously (on the source computer - I developed the GUI under
a version which doesn't have the compiler and then transferred the
.fig and .m files to a machine that does - the message I quoted in
my first post was taken from the machine with the compiler):

??? Previously accessible file "C:\MATLAB7\toolbox\ezyfit\efmenu.m" is
now inaccessible.

??? Error using ==> struct2handle
Error while evaluating figure CreateFcn.

Reloading v, hgS_070000 and c from the resaved file verifies that
the uimenu entries not there. So it looks like there is some other
remnant. I will poke around in v to see if I can locate another
reference to efmenu. Your general approach looks promising though!

Francis

Subject: Removing menus installed by 3rd party toolkits

From: someone

Date: 30 Jul, 2009 17:37:03

Message: 4 of 12

fburton@nyx.net (Francis Burton) wrote in message <1248974473.656045@irys.nyx.net>...
> In article <h4ru2e$842$1@fred.mathworks.com>, us <us@neurol.unizh.ch> wrote:
> >one of the very tedious solutions (r2009a)
> >
> > fnam='fig.fig'; % <- your fig name...
> > v=load(fnam,'-mat');
> > hgS_070000=v.hgS_070000; % <- may vary acc to your ML ver...
> > c=hgS_070000.children; % <- the fig's children
> > c.properties % <- see what they are/do...
> >% visually identify the bad children, eg,
> > ix=[1,4];
> > c(ix)=[]; % <- remove them
> > hgS_070000.children=c; % <- save the good children...
> > save('newfig.fig','hgS_070000');
> > openfig('newfig.fig');
> >
> >just a thought
> >us
>
> Thanks, us. The last four elements of c.properties were
>
> ans =
>
> Label: 'EzyFit'
> ApplicationData: [1x1 struct]
> Behavior: [1x1 struct]
> Visible: 'off'
>
> and I deleted them and wrote the data back to the figure file as
> instructed. However, when I opened it again I got the same message
> as previously (on the source computer - I developed the GUI under
> a version which doesn't have the compiler and then transferred the
> .fig and .m files to a machine that does - the message I quoted in
> my first post was taken from the machine with the compiler):
>
> ??? Previously accessible file "C:\MATLAB7\toolbox\ezyfit\efmenu.m" is
> now inaccessible.
>
> ??? Error using ==> struct2handle
> Error while evaluating figure CreateFcn.
>
> Reloading v, hgS_070000 and c from the resaved file verifies that
> the uimenu entries not there. So it looks like there is some other
> remnant. I will poke around in v to see if I can locate another
> reference to efmenu. Your general approach looks promising though!
>
> Francis
>
>

% Since this seems to be from the EzyFit toolbox (I assume),
% doesn't typing:
efmenu off
% at the command line remove the EzyFit menu items?

% (Then compile your GUI.)

Subject: Removing menus installed by 3rd party toolkits

From: fburton@nyx.net (Francis Burton)

Date: 30 Jul, 2009 17:46:16

Message: 5 of 12

In article <1248974473.656045@irys.nyx.net>,
Francis Burton <fburton@nyx.net> wrote:
>??? Previously accessible file "C:\MATLAB7\toolbox\ezyfit\efmenu.m" is
>now inaccessible.
>
>??? Error using ==> struct2handle
>Error while evaluating figure CreateFcn.
>
>Reloading v, hgS_070000 and c from the resaved file verifies that
>the uimenu entries not there. So it looks like there is some other
>remnant. I will poke around in v to see if I can locate another
>reference to efmenu. Your general approach looks promising though!

Ok, I found

hgS_070000.properties.CreateFcn = 'efmenu'

Setting it to '' got rid of the error messages. I think you just
saved me from repetitive strain injury. Thanks!

Francis

Subject: Removing menus installed by 3rd party toolkits

From: fburton@nyx.net (Francis Burton)

Date: 30 Jul, 2009 19:05:10

Message: 6 of 12

In article <h4slnv$9db$1@fred.mathworks.com>,
someone <someone@somewhere.net> wrote:
>> Reloading v, hgS_070000 and c from the resaved file verifies that
>> the uimenu entries not there. So it looks like there is some other
>> remnant. I will poke around in v to see if I can locate another
>> reference to efmenu. Your general approach looks promising though!
>>
>> Francis
>
>% Since this seems to be from the EzyFit toolbox (I assume),
>% doesn't typing:
>efmenu off
>% at the command line remove the EzyFit menu items?
>
>% (Then compile your GUI.)

EzyFit isn't installed on the computer with the compiler. The
figure file was originally created on a different computer when
EzyFit was installed. That's why it contains a reference to
efmenu. I didn't particularly want to install EzyFit on the
compiler computer. Would that have solved the problem - i.e.
allowed creation of an standalone without bits of EzyFit
inside it?

Francis

Subject: Removing menus installed by 3rd party toolkits

From: Frederic Moisy

Date: 25 Aug, 2009 21:56:03

Message: 7 of 12

Dear Francis,

As the author of the Ezyfit toolbox, I would like to answer to your message.

I am very sorry of this inconvenience. I know this bug since a long time,
and I have no idea on how to solve it. The best would be to find a way to
save the figures without including the non-mathworks menus, but I don't know
if it is possible. Or, when creating the menu, to specify a property in it so that
the menu is not saved in the figure or GUI. I would be happy to learn about that.

Best,
Fred.

Subject: Removing menus installed by 3rd party toolkits

From: fburton@nyx.net (Francis Burton)

Date: 26 Aug, 2009 10:32:07

Message: 8 of 12

In article <h71mlj$dcb$1@fred.mathworks.com>,
Frederic Moisy <moisy.nospam@fast.u-psud.fr> wrote:
>Dear Francis,
>
>As the author of the Ezyfit toolbox, I would like to answer to your message.
>
>I am very sorry of this inconvenience. I know this bug since a long time,
>and I have no idea on how to solve it. The best would be to find a way to
>save the figures without including the non-mathworks menus, but I don't know
>if it is possible. Or, when creating the menu, to specify a property in
>it so that
>the menu is not saved in the figure or GUI. I would be happy to learn
>about that.
>
>Best,
>Fred.

Dear Fred,

Your concern about the problem and eagerness to solve it is much
appreciated. I would like to add here my thanks for your efforts
in developing what is an excellent and useful toolkit - a piece
of software that has been of great help to me and colleagues.

If the Object Browser offered the ability to delete selected
objects, it would simple to fix this issue. However, I suspect
the folks who designed it never expected such a situation to
arise - or perhaps the consequences of inadvertently removing
an object are so terrible (like Eustace plucking the shrimp
from the anemone) that a deliberate decision was made not to
allow this.

Regards,
Francis

Subject: Removing menus installed by 3rd party toolkits

From: Nick Sinclair

Date: 5 Jul, 2010 05:48:04

Message: 9 of 12

If anyone is still having the specific EzyFit menu problem. Here's a distilled version of the code provided here which removes the efmenu menus and the references to it. Since the menu items all have Label fields of 'EzyFit', this just searches for these fields. My thanks to you guys for sorting this out. It was a constant nuisance to see those extra menu items.

Cheers.

%%%%%%%%%%%
fnam='FIGNAME.fig'; %<-- EDIT filename of figure
v=load(fnam,'-mat');
hgS_070000=v.hgS_070000;
c=hgS_070000.children;
clear ix; count = 0;
for i = 1:length(c),
    if isfield(c(i).properties,'Label'),
        if(strfind(c(i).properties.Label,'EzyFit'))
            count = count+1;
            ix(count) = i;
        end
    end
end
c(ix)=[];
hgS_070000.children=c;
hgS_070000.properties.CreateFcn = '';
fnameout = 'FIGNAMEFIXED.fig'; %<-- EDIT filename of figure
save(fnameout,'hgS_070000');
openfig(fnameout);
%%%%%%%%%%%%%%%

fburton@nyx.net (Francis Burton) wrote in message <1251282726.754049@irys.nyx.net>...
> In article <h71mlj$dcb$1@fred.mathworks.com>,
> Frederic Moisy <moisy.nospam@fast.u-psud.fr> wrote:
> >Dear Francis,
> >
> >As the author of the Ezyfit toolbox, I would like to answer to your message.
> >
> >I am very sorry of this inconvenience. I know this bug since a long time,
> >and I have no idea on how to solve it. The best would be to find a way to
> >save the figures without including the non-mathworks menus, but I don't know
> >if it is possible. Or, when creating the menu, to specify a property in
> >it so that
> >the menu is not saved in the figure or GUI. I would be happy to learn
> >about that.
> >
> >Best,
> >Fred.
>
> Dear Fred,
>
> Your concern about the problem and eagerness to solve it is much
> appreciated. I would like to add here my thanks for your efforts
> in developing what is an excellent and useful toolkit - a piece
> of software that has been of great help to me and colleagues.
>
> If the Object Browser offered the ability to delete selected
> objects, it would simple to fix this issue. However, I suspect
> the folks who designed it never expected such a situation to
> arise - or perhaps the consequences of inadvertently removing
> an object are so terrible (like Eustace plucking the shrimp
> from the anemone) that a deliberate decision was made not to
> allow this.
>
> Regards,
> Francis

Subject: Removing menus installed by 3rd party toolkits

From: Frederic Moisy

Date: 5 Jul, 2010 10:29:04

Message: 10 of 12

Dear Nick

Thank you so much for your patch, which works fine.
I will include it soon to the next release of Ezyfit.

Sincerely,
Fred.


"Nick Sinclair" <nicholas.sinclair@gmail.com> wrote in message <i0rrmk$j8l$1@fred.mathworks.com>...
> If anyone is still having the specific EzyFit menu problem. Here's a distilled version of the code provided here which removes the efmenu menus and the references to it. Since the menu items all have Label fields of 'EzyFit', this just searches for these fields. My thanks to you guys for sorting this out. It was a constant nuisance to see those extra menu items.
>
> Cheers.
>
> %%%%%%%%%%%
> fnam='FIGNAME.fig'; %<-- EDIT filename of figure
> v=load(fnam,'-mat');
> hgS_070000=v.hgS_070000;
> c=hgS_070000.children;
> clear ix; count = 0;
> for i = 1:length(c),
> if isfield(c(i).properties,'Label'),
> if(strfind(c(i).properties.Label,'EzyFit'))
> count = count+1;
> ix(count) = i;
> end
> end
> end
> c(ix)=[];
> hgS_070000.children=c;
> hgS_070000.properties.CreateFcn = '';
> fnameout = 'FIGNAMEFIXED.fig'; %<-- EDIT filename of figure
> save(fnameout,'hgS_070000');
> openfig(fnameout);
> %%%%%%%%%%%%%%%
>
> fburton@nyx.net (Francis Burton) wrote in message <1251282726.754049@irys.nyx.net>...
> > In article <h71mlj$dcb$1@fred.mathworks.com>,
> > Frederic Moisy <moisy.nospam@fast.u-psud.fr> wrote:
> > >Dear Francis,
> > >
> > >As the author of the Ezyfit toolbox, I would like to answer to your message.
> > >
> > >I am very sorry of this inconvenience. I know this bug since a long time,
> > >and I have no idea on how to solve it. The best would be to find a way to
> > >save the figures without including the non-mathworks menus, but I don't know
> > >if it is possible. Or, when creating the menu, to specify a property in
> > >it so that
> > >the menu is not saved in the figure or GUI. I would be happy to learn
> > >about that.
> > >
> > >Best,
> > >Fred.
> >
> > Dear Fred,
> >
> > Your concern about the problem and eagerness to solve it is much
> > appreciated. I would like to add here my thanks for your efforts
> > in developing what is an excellent and useful toolkit - a piece
> > of software that has been of great help to me and colleagues.
> >
> > If the Object Browser offered the ability to delete selected
> > objects, it would simple to fix this issue. However, I suspect
> > the folks who designed it never expected such a situation to
> > arise - or perhaps the consequences of inadvertently removing
> > an object are so terrible (like Eustace plucking the shrimp
> > from the anemone) that a deliberate decision was made not to
> > allow this.
> >
> > Regards,
> > Francis

Subject: Removing menus installed by 3rd party toolkits

From: Frederic Moisy

Date: 29 Jul, 2010 14:22:04

Message: 11 of 12

The new version of ezyfit (V 2.40), available at
http://www.mathworks.com/matlabcentral/fileexchange/10176-ezyfit-2-40
now includes the patch.
Use the new function 'remove_efmenu_fig' in order to
remove the ezyfit menu of a given file.
Frederic.


"Frederic Moisy" <moisy@fast.u-psud.fr> wrote in message <i0sc5g$10$1@fred.mathworks.com>...
> Dear Nick
>
> Thank you so much for your patch, which works fine.
> I will include it soon to the next release of Ezyfit.
>
> Sincerely,
> Fred.
>
>
> "Nick Sinclair" <nicholas.sinclair@gmail.com> wrote in message <i0rrmk$j8l$1@fred.mathworks.com>...
> > If anyone is still having the specific EzyFit menu problem. Here's a distilled version of the code provided here which removes the efmenu menus and the references to it. Since the menu items all have Label fields of 'EzyFit', this just searches for these fields. My thanks to you guys for sorting this out. It was a constant nuisance to see those extra menu items.
> >
> > Cheers.
> >
> > %%%%%%%%%%%
> > fnam='FIGNAME.fig'; %<-- EDIT filename of figure
> > v=load(fnam,'-mat');
> > hgS_070000=v.hgS_070000;
> > c=hgS_070000.children;
> > clear ix; count = 0;
> > for i = 1:length(c),
> > if isfield(c(i).properties,'Label'),
> > if(strfind(c(i).properties.Label,'EzyFit'))
> > count = count+1;
> > ix(count) = i;
> > end
> > end
> > end
> > c(ix)=[];
> > hgS_070000.children=c;
> > hgS_070000.properties.CreateFcn = '';
> > fnameout = 'FIGNAMEFIXED.fig'; %<-- EDIT filename of figure
> > save(fnameout,'hgS_070000');
> > openfig(fnameout);
> > %%%%%%%%%%%%%%%
> >
> > fburton@nyx.net (Francis Burton) wrote in message <1251282726.754049@irys.nyx.net>...
> > > In article <h71mlj$dcb$1@fred.mathworks.com>,
> > > Frederic Moisy <moisy.nospam@fast.u-psud.fr> wrote:
> > > >Dear Francis,
> > > >
> > > >As the author of the Ezyfit toolbox, I would like to answer to your message.
> > > >
> > > >I am very sorry of this inconvenience. I know this bug since a long time,
> > > >and I have no idea on how to solve it. The best would be to find a way to
> > > >save the figures without including the non-mathworks menus, but I don't know
> > > >if it is possible. Or, when creating the menu, to specify a property in
> > > >it so that
> > > >the menu is not saved in the figure or GUI. I would be happy to learn
> > > >about that.
> > > >
> > > >Best,
> > > >Fred.
> > >
> > > Dear Fred,
> > >
> > > Your concern about the problem and eagerness to solve it is much
> > > appreciated. I would like to add here my thanks for your efforts
> > > in developing what is an excellent and useful toolkit - a piece
> > > of software that has been of great help to me and colleagues.
> > >
> > > If the Object Browser offered the ability to delete selected
> > > objects, it would simple to fix this issue. However, I suspect
> > > the folks who designed it never expected such a situation to
> > > arise - or perhaps the consequences of inadvertently removing
> > > an object are so terrible (like Eustace plucking the shrimp
> > > from the anemone) that a deliberate decision was made not to
> > > allow this.
> > >
> > > Regards,
> > > Francis

Subject: Removing menus installed by 3rd party toolkits

From: Nick Sinclair

Date: 6 Aug, 2010 16:04:04

Message: 12 of 12

Cool. Thanks, Frederic. I do like EzyFit, btw. I just had problems with it adding menus to all of my guide-created gui's. Keep up the good work.

-nick

"Frederic Moisy" <moisy@fast.u-psud.fr> wrote in message <i2s2qc$j28$1@fred.mathworks.com>...
> The new version of ezyfit (V 2.40), available at
> http://www.mathworks.com/matlabcentral/fileexchange/10176-ezyfit-2-40
> now includes the patch.
> Use the new function 'remove_efmenu_fig' in order to
> remove the ezyfit menu of a given file.
> Frederic.
>
>
> "Frederic Moisy" <moisy@fast.u-psud.fr> wrote in message <i0sc5g$10$1@fred.mathworks.com>...
> > Dear Nick
> >
> > Thank you so much for your patch, which works fine.
> > I will include it soon to the next release of Ezyfit.
> >
> > Sincerely,
> > Fred.
> >
> >
> > "Nick Sinclair" <nicholas.sinclair@gmail.com> wrote in message <i0rrmk$j8l$1@fred.mathworks.com>...
> > > If anyone is still having the specific EzyFit menu problem. Here's a distilled version of the code provided here which removes the efmenu menus and the references to it. Since the menu items all have Label fields of 'EzyFit', this just searches for these fields. My thanks to you guys for sorting this out. It was a constant nuisance to see those extra menu items.
> > >
> > > Cheers.
> > >
> > > %%%%%%%%%%%
> > > fnam='FIGNAME.fig'; %<-- EDIT filename of figure
> > > v=load(fnam,'-mat');
> > > hgS_070000=v.hgS_070000;
> > > c=hgS_070000.children;
> > > clear ix; count = 0;
> > > for i = 1:length(c),
> > > if isfield(c(i).properties,'Label'),
> > > if(strfind(c(i).properties.Label,'EzyFit'))
> > > count = count+1;
> > > ix(count) = i;
> > > end
> > > end
> > > end
> > > c(ix)=[];
> > > hgS_070000.children=c;
> > > hgS_070000.properties.CreateFcn = '';
> > > fnameout = 'FIGNAMEFIXED.fig'; %<-- EDIT filename of figure
> > > save(fnameout,'hgS_070000');
> > > openfig(fnameout);
> > > %%%%%%%%%%%%%%%
> > >
> > > fburton@nyx.net (Francis Burton) wrote in message <1251282726.754049@irys.nyx.net>...
> > > > In article <h71mlj$dcb$1@fred.mathworks.com>,
> > > > Frederic Moisy <moisy.nospam@fast.u-psud.fr> wrote:
> > > > >Dear Francis,
> > > > >
> > > > >As the author of the Ezyfit toolbox, I would like to answer to your message.
> > > > >
> > > > >I am very sorry of this inconvenience. I know this bug since a long time,
> > > > >and I have no idea on how to solve it. The best would be to find a way to
> > > > >save the figures without including the non-mathworks menus, but I don't know
> > > > >if it is possible. Or, when creating the menu, to specify a property in
> > > > >it so that
> > > > >the menu is not saved in the figure or GUI. I would be happy to learn
> > > > >about that.
> > > > >
> > > > >Best,
> > > > >Fred.
> > > >
> > > > Dear Fred,
> > > >
> > > > Your concern about the problem and eagerness to solve it is much
> > > > appreciated. I would like to add here my thanks for your efforts
> > > > in developing what is an excellent and useful toolkit - a piece
> > > > of software that has been of great help to me and colleagues.
> > > >
> > > > If the Object Browser offered the ability to delete selected
> > > > objects, it would simple to fix this issue. However, I suspect
> > > > the folks who designed it never expected such a situation to
> > > > arise - or perhaps the consequences of inadvertently removing
> > > > an object are so terrible (like Eustace plucking the shrimp
> > > > from the anemone) that a deliberate decision was made not to
> > > > allow this.
> > > >
> > > > Regards,
> > > > Francis

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
code us 30 Jul, 2009 06:54:04
load us 30 Jul, 2009 06:54:04
save us 30 Jul, 2009 06:54:04
linear indexing us 30 Jul, 2009 06:54:04
graphics handle us 30 Jul, 2009 06:54:04
rssFeed for this Thread

Contact us at files@mathworks.com