Azzera filtri
Azzera filtri

How to use GUIDE to insert a countdown timer into GUI ?

6 visualizzazioni (ultimi 30 giorni)
Hi,
I am trying to insert a countdown timer into my gui using guide. I did a lot of researh on how to do this, and the best example I've found that meets my need is from Matt Fig, link below.
My issue is that I don't want to use the S.pb and .tx and such to do it, I need to do it using the handles; that is I insert pushbutton and textbox in guide go from there. I haven't been able to translate the code from the S. to the handles structure successfully.
Your help as always is much appreciated.
Thank you.
Code supplied by Matt Fig.
function [] = timer_examp()
S.fh = figure('units','pixels',...
'position',[500 500 200 100],...
'menubar','none',...
'name','Timer_examp',...
'numbertitle','off',...
'resize','off');
S.tx = uicontrol('style','text',...
'unit','pix',...
'position',[10 60 180 30],...
'fontsize',14,...
'string','10');
S.tmr = timer('Name','Countdown',...
'Period',1,... % 10 minute snooze time.
'StartDelay',.01,...
'ExecutionMode','fixedSpacing',...
'StopFcn',@deleter); % Function def. below.
S.pb = uicontrol('style','push',...
'units','pix',...
'position',[10 10 180 40],...
'fontsize',14,...
'string','Start Countdown!',...
'callback',{@pb_call,S});
set(S.tmr,'TimerFcn',{@update_disp,S},'StartDelay',5);
function [] = pb_call(varargin)
% Callback for pushbutton, deletes one line from listbox.
S = varargin{3}
% Need to check string!
set(S.tmr,'TasksToExecute',str2double(get(S.tx,'string')))
start(S.tmr);
function [] = update_disp(varargin)
S = varargin{3};
N = str2double(get(S.tx,'string'));
set(S.tx,'string',num2str(N-1));
function deleter(obj,edata) %#ok M-Lint doesn't know the callback fmt.
% Callback for stopfcn.
wait(obj);
delete(obj);
Yes this code works indeed, but for my purpose, I need to be able to translate it into the form as I described above (USING GUIDE).
Thanks.

Risposte (0)

Categorie

Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by