GUI FAULT INDICATOR (GREEN, RED)

1 Ansicht (letzte 30 Tage)
Daniel
Daniel am 25 Apr. 2016
Kommentiert: Meade am 25 Apr. 2016
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 Kommentare
Adam
Adam am 25 Apr. 2016
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 am 25 Apr. 2016
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

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Interactive Control and Callbacks 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