GUI FAULT INDICATOR (GREEN, RED)

3 次查看(过去 30 天)
Daniel
Daniel 2016-4-25
评论: Meade 2016-4-25
HI, i want a FAULT indicator in my GUI. lets say A red circle, or a green circle. is there something simple, built in the GUI that i can use? i dont really want to draw a circle from scratch every place i want an indicator
  3 个评论
Adam
Adam 2016-4-25
If you are using R2016a and the App Designer you can use
doc uilamp
to do this I would think. I haven't used the App Designer or its components yet myself though so I don't know what the limitations are on GUIs created that way are.
Meade
Meade 2016-4-25
For dead-simple notification, just fill the BackgroundColor of your favorie ui object.
Try this as a template:
function toggleTest
% Make fig
figure('Visible','off',...
'OuterPosition', [0 40 400 400],...
'MenuBar', 'none',...
'ToolBar', 'none');
hFig = gcf;
% A simple pushbutton
uicontrol(hFig,'Style','pushbutton',...
'Units', 'norm',...
'Position',[0.2 0.6 0.6 0.25],...
'String','TOGGLE',...
'Callback',@toggleColor);
% STATUS INDICATOR --------------------------
uipanel(gcf,'units','norm',...
'Position',[0.2 0.2 0.6 0.25],...
'BackgroundColor','g',...
'tag', 'PANEL_TOGGLE')
% --------------------------------------------
% Save toggle state
data.TOGGLE_STATE = true;
% Pass Handles
data.Handles = guihandles(hFig);
% Save & Launch
guidata(hFig,data);
movegui(hFig,'center')
hFig.Visible = 'on';
end
function toggleColor(hObj,~)
h = guidata(hObj);
switch h.TOGGLE_STATE
case true
h.Handles.PANEL_TOGGLE.BackgroundColor = 'r';
case false
h.Handles.PANEL_TOGGLE.BackgroundColor = 'g';
end
h.TOGGLE_STATE = ~h.TOGGLE_STATE
guidata(hObj,h);
end

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by