Filter löschen
Filter löschen

update date and time in gui

5 Ansichten (letzte 30 Tage)
Stalin Samuel
Stalin Samuel am 21 Jan. 2016
function demo1()
H.f = figure('Name','DEMO1');
set(H.f,'Units','Pixels','Position',get(0,'ScreenSize'));% adjust figure size as per the screen size
H.pb1 = uicontrol('style','push',...
'units','pixels',...
'position',[400 800 280 30],...
'fontsize',14,...
'string', datestr(now)); % datestr(now) is used to get current date and time
end
Now my intention is to update the date and time and it should be run like a real time clock

Antworten (1)

Walter Roberson
Walter Roberson am 21 Jan. 2016
You are going to want to use a timer to update the graphics. Odd that you would put it on a pushbutton rather than as a uicontrol('style','text'), but whatever.
The timer that does the update is going to need to get the handle of the graphics object to update. It would find that easier if you returned your H out of your function, or if you had at least added a Tag to the uicontrol so that it could (inefficiently but functionally) search all the graphics objects by name. As it is now, the timer is going to have to locate the figure by name and then dig inside the figure to find the uicontrol...
  1 Kommentar
Rainaire Hansford
Rainaire Hansford am 25 Mai 2019
Hi Stalin,
Any way to apply your function on a script?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by