フィルターのクリア

update date and time in gui

5 ビュー (過去 30 日間)
Stalin Samuel
Stalin Samuel 2016 年 1 月 21 日
コメント済み: Rainaire Hansford 2019 年 5 月 25 日
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

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 1 月 21 日
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 件のコメント
Rainaire Hansford
Rainaire Hansford 2019 年 5 月 25 日
Hi Stalin,
Any way to apply your function on a script?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by