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

Re: GUI and timer

Roy Schestowitz wrote:
>
>
> 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,'execution
> mo
>> 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>
>

Solution is very simple - from matlab command line just start 'GUIDE
<myapp>' and right click on blank area -> GUI options ->
command line accessibility -> & set other (use settings ...). Then
launch object browser and double-click on figure (now you have
figure's properties). Last, find 'HandleVisibility' and set it to
'On' ! Do that for axes also, and you have all things done.

Bye,
Darko

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