How do I create a call back function that updates a "Label" when I push a button? (Calculator)
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Shane Grover
am 29 Mär. 2019
Beantwortet: Image Analyst
am 29 Mär. 2019
Hello all, I am trying to impliment a GUI for my Calculator program. I have the GUI fully laid out and I am attempting to get my Label to update when I push a button. I am currently trying to get it to work by creating a call back for my button, lets call it Button_1, the button is supposed to set the value of the Label to 1. Any help would be much appriciated, I do not know where to start.
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 29 Mär. 2019
Set the string property in the button callback:
function button1_Callback(hObject, eventdata, handles)
handles.Label.String = '1'; % Whatever
0 Kommentare
Weitere Antworten (1)
Kevin Phung
am 29 Mär. 2019
assign a tag to your label, which I assume is a text graphic object.
example:
txt1.Tag = 'label1';
function button_1callback(hObj,event)
label1= findobj(gcf,'Tag','label1');
label1.String = 'whateverValue';
end
0 Kommentare
Siehe auch
Kategorien
Mehr zu Model, Block, and Port 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!