Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Starting a timer in a GUI from another GUI

Subject: Starting a timer in a GUI from another GUI

From: Javier

Date: 8 Jul, 2010 13:40:08

Message: 1 of 3


Hi guys,

I have a Gui in which I have a timer always running. Then there's a button that opens another GUI. I want to do that while the second GUI is opened the timer in the first is paused.

My idea is, in the main GUI, in the callback for the 2nd Gui opening to stop(timername) and then in the CloseRequestFcn of the 2nd GUI to start(timername).

I think it has to be another more clever way to do it.

If my way is good the question is: how to start the timer written in the 1st GUI from the 2nd GUI?

Thanks a lot

Subject: Starting a timer in a GUI from another GUI

From: Sean

Date: 8 Jul, 2010 15:01:15

Message: 2 of 3

"Javier " <jagon@postal.uv.es> wrote in message <i14kfo$2jo$1@fred.mathworks.com>...
>
> Hi guys,
>
> I have a Gui in which I have a timer always running. Then there's a button that opens another GUI. I want to do that while the second GUI is opened the timer in the first is paused.
>
> My idea is, in the main GUI, in the callback for the 2nd Gui opening to stop(timername) and then in the CloseRequestFcn of the 2nd GUI to start(timername).
> I think it has to be another more clever way to do it.
>

That sounds reasonable enough. Though you might just want to stop the timer in the first GUI when the button is pushed.

> If my way is good the question is: how to start the timer written in the 1st GUI from the 2nd GUI?

Set the handles to your timer in appdata in your first GUI i.e.
%%%First GUI
>>T1 = timer...
>>setappdata(0,'T1',T1);
>>start(T1)

%%%Second GUI
>>T1 = getappdata(0,'T1');
>>stop(T1);

Good Luck!

Subject: Starting a timer in a GUI from another GUI

From: Javier

Date: 12 Jul, 2010 08:57:06

Message: 3 of 3

"Sean " <sean.dewolski@nospamplease.umit.maine.edu> wrote in message <i14p7r$ilu$1@fred.mathworks.com>...
> "Javier " <jagon@postal.uv.es> wrote in message <i14kfo$2jo$1@fred.mathworks.com>...
> >
> > Hi guys,
> >
> > I have a Gui in which I have a timer always running. Then there's a button that opens another GUI. I want to do that while the second GUI is opened the timer in the first is paused.
> >
> > My idea is, in the main GUI, in the callback for the 2nd Gui opening to stop(timername) and then in the CloseRequestFcn of the 2nd GUI to start(timername).
> > I think it has to be another more clever way to do it.
> >
>
> That sounds reasonable enough. Though you might just want to stop the timer in the first GUI when the button is pushed.
>
> > If my way is good the question is: how to start the timer written in the 1st GUI from the 2nd GUI?
>
> Set the handles to your timer in appdata in your first GUI i.e.
> %%%First GUI
> >>T1 = timer...
> >>setappdata(0,'T1',T1);
> >>start(T1)
>
> %%%Second GUI
> >>T1 = getappdata(0,'T1');
> >>stop(T1);
>
> Good Luck!



Didn't know set and getappdata. Thanks a lot!
:)

Tags for this Thread

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.

Contact us