Clear Filters
Clear Filters

Info

This question is closed. Reopen it to edit or answer.

how can i get the value change of my screen_box if i press any button from my calculator

1 view (last 30 days)
function []=calculator_gui() defaultbackground=get(0,'defaultUicontrolBackgroundcolor'); roi_fig=figure('Name','Calculator'); % open_file_box=uicontrol('Parent',roi_fig,'Style','Pushbutton','Units','normalized','Position',[0.05 0.5 0.2 0.09],'String','Open File'); % test_box=uicontrol('Parent',roi_fig,'Style','Pushbutton','Units','normalized','Position',[0.2 .15 .2 .12],'String','test'); % filename_box=uicontrol('Parent',roi_fig,'Style','Text','Units','normalized','Position',[0.45 0.9 0.35 0.045],'Background',[1 1 1],'String','Filename'); % screen= uicontrol('Parent',roi_fig,'Style','edit','Units','normalised','Position',[0.2 .8 .15 .15],'String','0','Background',[1 1 1]); screen_box=uicontrol('Parent',roi_fig,'Style','edit','Units','normalized','Position',[0 0.81 1 .2],'String','0','Background',[1 1 1]); num_one_box=uicontrol('Parent',roi_fig,'Style','Pushbutton','Units','normalized','Position',[0 .54 .2 .27],'String','1','Background',[1 1 1]); num_two_box=uicontrol('Parent',roi_fig,'Style','Pushbutton','Units','normalized','Position',[0.2 .54 .2 .27],'String','2','Background',[1 1 1],'Callback',@num_one_fn); num_three_box=uicontrol('Parent',roi_fig,'Style','Pushbutton','Units','normalized','Position',[.4 .54 .2 .27],'String','3','Background',[1 1 1]); num_four_box=uicontrol('Parent',roi_fig,'Style','Pushbutton','Units','normalized','Position',[0 .27 .2 .27],'String','4','Background',[1 1 1]); num_five_box=uicontrol('Parent',roi_fig,'Style','Pushbutton','Units','normalized','Position',[0.2 .27 .2 .27],'String','5','Background',[1 1 1]); num_one_box=uicontrol('Parent',roi_fig,'Style','Pushbutton','Units','normalized','Position',[0.4 .27 .2 .27],'String','6','Background',[1 1 1]); num_one_box=uicontrol('Parent',roi_fig,'Style','Pushbutton','Units','normalized','Position',[0 0 .2 .27],'String','7','Background',[1 1 1]); num_one_box=uicontrol('Parent',roi_fig,'Style','Pushbutton','Units','normalized','Position',[0.2 0 .2 .27],'String','8','Background',[1 1 1]); num_one_box=uicontrol('Parent',roi_fig,'Style','Pushbutton','Units','normalized','Position',[0.4 0 .2 .27],'String','9','Background',[1 1 1]); num_one_box=uicontrol('Parent',roi_fig,'Style','Pushbutton','Units','normalized','Position',[0.6 .54 .2 .27],'String','0','Background',[1 1 1]); add_box=uicontrol('Parent',roi_fig,'Style','Pushbutton','Units','normalized','Position',[.6 .27 .2 .27],'String','+','Background',[ 1 1 1]); substract_box=uicontrol('Parent',roi_fig,'Style','Pushbutton','Units','normalized','Position',[.6 0 .2 .27],'String','-','Background',[ 1 1 1]); multiply_box=uicontrol('Parent',roi_fig,'Style','Pushbutton','Units','normalized','Position',[.8 .54 .2 .27],'String','*','Background',[ 1 1 1]); divide_box=uicontrol('Parent',roi_fig,'Style','Pushbutton','Units','normalized','Position',[.8 .27 .2 .27],'String','/','Background',[ 1 1 1]); equal_box=uicontrol('Parent',roi_fig,'Style','Pushbutton','Units','normalized','Position',[.8 0 .2 .27],'String','=','Background',[ 1 1 1]);
function []=num_one_fn(object,handles) set(screen_box,'String','1'); end
end

Answers (0)

This question is closed.

Tags

Community Treasure Hunt

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

Start Hunting!