Home Messages Index
[Date Prev][Date Next][Thread Prev][Thread Next]
Author IndexDate IndexThread Index

Re: GUI and timer

  • Subject: Re: GUI and timer
  • From: Roy Schestowitz <newsgroups@schestowitz.com>
  • Date: Mon, 10 Jan 2005 02:03:56 +0000
  • Newsgroups: comp.soft-sys.matlab
  • References: <yw1hbq676m35@legacy> <crqied$2qhk$1@godfrey.mcc.ac.uk> <eef7fc0.1@webx.raydaftYaTP>
  • User-agent: KNode/0.7.2
MKA wrote:

> Roy Schestowitz wrote:
>>
>>
>> MKA wrote:
>>
>>> Any suggestions for using the timer function to display a
> running
>>> clock in a static text or an edit text object using guide.
>>>
>>> Thanks in advance.
>>
>> That's quite simple. All you need to do is set the label or
>> editable text
>> box to the value returned by the timer function.
>>
>> Instead of re-implementing, try using what has been done:
>>
>>
<http://www.mathworks.nl/matlabcentral/fileexchange/loadFile.do?objectId=5527&objectType=file>
>>
>>
<http://www.mathworks.nl/matlabcentral/fileexchange/loadFile.do?objectId=2263&objectType=file>
>>
>> Roy
>>
>> --
>> Roy Schestowitz
>> <http://schestowitz.com>
>>
> Thanks Roy for your help
> I am trying to make it simple, but I am afraid it is not
> I open Guide, insert a static text
> For the opening function I use
> 
> % UIWAIT makes bclock wait for user response (see UIRESUME)
> % uiwait(handles.figure1);
> 
> set(handles.figure1,'closerequestfcn',@closerequestfcn);
> handles.TimerObject=timer('timerfcn',@TimerFcn,'period',1,'executionmo
> de','fixedrate');
> start(handles.TimerObject);
> 
> Then I add the next two functions at the end
> 
> function []=TimerFcn(varargin)
> % Display Clock
> handles=guihandles;
> set(handles.text1,'String',datestr(clock));
> 
> function []=closerequestfcn(varargin)
> % Shut off the timer and close the figure when the x is clicked
> handles=guihandles;
> d=timerfind;stop(d);delete(d);
> delete(handles.figure1);
> 
> After the first timer event it opens a new figure (also called
> figure1 like the GUI figure. Now it does not find the text1 object
> and stops to work.
> 
> Can you see where my logic faults.

Without GUIDE and the running demo, I'm afraid that I find it difficult to
debug or even follow. It seems possible to me that you overcomplicated
things. You need a single callback to be executed every 1 second; therein
you set the clock. The rest of the code is detail which overcomplicates the
problem to a reader. Try to divide it into logical blocks and separate out
the cause of the error. It would simplify things.


-- 
Roy Schestowitz
http://schestowitz.com

[Date Prev][Date Next][Thread Prev][Thread Next]
Author IndexDate IndexThread Index