Add clock in GUI update it.

2 vues (au cours des 30 derniers jours)
mohsen Kondori
mohsen Kondori le 19 Avr 2019
Commenté : Walter Roberson le 23 Avr 2019
Hi Dears
How add a clock in gui and update it continuesly, please explain step by step.
Thanks.
my gui matlab code:
function varargout = mygui(varargin)
% gui_mainfcn
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @mygui_OpeningFcn, ...
'gui_OutputFcn', @mygui_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
function mygui_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
colordef white
imshow('PVP.tif')
set(handles.Clockc,'String',cellstr(datestr(date, 'yyyy/mm/dd')));
% set(handles.timee, 'String',datestr(datetime('now','TimeZone','local','Format','d-MMM-y HH:mm:ss Z')));
function varargout = mygui_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
function edit1_Callback(hObject, eventdata, handles)
function edit1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function startimg1_Callback(hObject, eventdata, handles)
function startimg1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function slice1_Callback(hObject, eventdata, handles)
function slice1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function slice11_Callback(hObject, eventdata, handles)
function slice11_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function NameFile11_Callback(hObject, eventdata, handles)
function NameFile11_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function pushbutton1_Callback(hObject, eventdata, handles)
direction=get(handles.direction1,'string');
NameFile1=get(handles.NameFile11,'string');
startimg=str2num(get(handles.startimg1,'string'));
slice1=str2num(get(handles.slice11,'string'));
endimg=str2num(get(handles.endimg1,'string'));
coronal=get(handles.coronal1,'string');
sagital=get(handles.sagital1,'string');
suffix='.xlsb';
NameFile=strcat(NameFile1,suffix);
copyfile('CTtemplate.xlsb',NameFile);
close all
FigureTry2(direction,startimg,slice1, endimg,NameFile1);
CTMain(direction,startimg,slice1, endimg,NameFile1,coronal,sagital);
%%
function direction1_Callback(hObject, eventdata, handles)
function direction1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function coronal1_Callback(hObject, eventdata, handles)
function coronal1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function sagital1_Callback(hObject, eventdata, handles)
function sagital1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function endimg1_Callback(hObject, eventdata, handles)
function endimg1_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function axes1_CreateFcn(hObject, eventdata, handles)
function CTimg_CreateFcn(hObject, eventdata, handles)
imshow('PVP2.tif')
function Clockc_Callback(hObject, eventdata, handles)
function Clockc_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function Clockk_Callback(hObject, eventdata, handles)
function Clockk_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function edit14_Callback(hObject, eventdata, handles)
function edit14_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function timee_Callback(hObject, eventdata, handles)
% hObject handle to timee (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of timee as text
% str2double(get(hObject,'String')) returns contents of timee as a double
% --- Executes during object creation, after setting all properties.
function timee_CreateFcn(hObject, eventdata, handles)
% hObject handle to timee (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
  3 commentaires
mohsen Kondori
mohsen Kondori le 23 Avr 2019
Hi dears
I can not do it. Please give me more guidance
Tanks.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Clocks and Timers dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by