From: Mark on
Is there a way to simulate 'clicking' on a pushbutton upon GUI creation? I do not want to put the code in the gui's OpeningFcn because the code behind the pushbutton selects data that is transferred back to the main gui screen, populating a listbox and setting variables that are used for plotting and data analysis. The user could click on the pushbutton, but this task will be done every time the gui is used, so I would like to automate this process.

Thanks for the help.
From: ImageAnalyst on
I'm not sure what "I do not want to put the code in the gui's
OpeningFcn because the code behind the pushbutton selects data that is
transferred back to the main gui screen, populating a listbox and
setting variables that are used for plotting and data analysis. "
means. If you call that code, it will do the same thing no matter
whether it's called from the OpenFcn or from the button click
callback, unless you put in some kind of flag to do different things,
something like this

function mygui_Openfcn()
....
inOpenFcn = true;
myInitilization(inOpenFcn);
....


function button1_clickCallback(....)
....
inOpenFcn = false;
myInitilization(inOpenFcn);
....


function myInitilization(inOpenFcn)
....
if inOpenFcn
% Do stuff you want to do when called from the openfcn
else
% Do stuff you want to do when called NOT from the openfcn
end
....
From: Mark on
ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <f99098ff-2782-4515-82f9-70c5c843cf05(a)u7g2000yqm.googlegroups.com>...
> I'm not sure what "I do not want to put the code in the gui's
> OpeningFcn because the code behind the pushbutton selects data that is
> transferred back to the main gui screen, populating a listbox and
> setting variables that are used for plotting and data analysis. "
> means. If you call that code, it will do the same thing no matter
> whether it's called from the OpenFcn or from the button click
> callback, unless you put in some kind of flag to do different things,
> something like this
>
> function mygui_Openfcn()
> ....
> inOpenFcn = true;
> myInitilization(inOpenFcn);
> ....
>
>
> function button1_clickCallback(....)
> ....
> inOpenFcn = false;
> myInitilization(inOpenFcn);
> ....
>
>
> function myInitilization(inOpenFcn)
> ....
> if inOpenFcn
> % Do stuff you want to do when called from the openfcn
> else
> % Do stuff you want to do when called NOT from the openfcn
> end
> ....

That does what I need. Thanks