HOW DO I INSERT INPUTS USING GUI?

3 次查看(过去 30 天)
Hi,
iam trying to insert inputs using GUI once i click on the pushbutton i cant see the inputs on the worksapce,i wasnt able to perfurme the next step because its based on these inputs i used the following code to insert the inputs
dims = [1 35];
dlgtitle = 'Input';
prompt = {'radi_1:', 'radi_2:', ...
'suff_1:','suff_2:','num:','first:','last:'};
answer = inputdlg(prompt,dlgtitle,dims);
[radi_1,radi_2t,suff_1 ,suff_2,num,first,last] = deal(answer{:})

回答(1 个)

David Hill
David Hill 2022-8-29
Here is a very simple example.
function GUI()
%write a statement in each of the input boxes
gui = figure('MenuBar','none','Name','YourName','Visible','off','Position',[300,300,850,500]);
cipher = uipanel('Title','YourTitle','Units','pixels','Position',[8 8 700 484],'BackgroundColor',[0.9 0.9 0.9]);
input1 = uicontrol('Parent',cipher,'Style','text','String','Do:','Units','pixels','Position',[3 420 50 16],'BackgroundColor',[0.9 0.9 0.9],'HorizontalAlignment','left');
input_area1 = uicontrol('Parent',cipher,'Style','edit','String','','Max',2,'Units','pixels','Position',[52 380 638 70],'BackgroundColor',[1 1 1],'HorizontalAlignment','left');
input2 = uicontrol('Parent',cipher,'Style','text','String','Key:','Units','pixels','Position',[6 360 43 16],'BackgroundColor',[0.9 0.9 0.9],'HorizontalAlignment','left');
input_area2 = uicontrol('Parent',cipher,'Style','edit','String','','Max',2,'Units','pixels','Position',[52 347 638 30],'BackgroundColor',[1 1 1],'HorizontalAlignment','left');
output = uicontrol('Parent',cipher,'Style','text','String','Get:','Units','pixels','Position',[3 315 50 16],'BackgroundColor',[0.9 0.9 0.9],'HorizontalAlignment','left');
output_area = uicontrol('Parent',cipher,'Style','edit','String','','Max',2,'Units','pixels','Position',[52 120 638 220],'BackgroundColor',[1 1 1],'HorizontalAlignment','left');
options = uibuttongroup('Title','Options','Units','pixels','Position',[714 260 130 232],'BackgroundColor',[0.9 0.9 0.9]);
doButton = uicontrol('Parent',options,'Style','pushbutton','String','DoButton','Units','pixels','Position',[4 130 120 60],'BackgroundColor',[0.9 0.9 0.9],'Callback',@doB_Callback);
getButton = uicontrol('Parent',options,'Style','pushbutton','String','GetButton','Units','pixels','Position',[4 70 120 60],'BackgroundColor',[0.9 0.9 0.9],'Callback',@getB_Callback);
reset = uicontrol('Parent',options,'Style','pushbutton','String','Reset','Units','pixels','Position',[4 5 120 60],'BackgroundColor',[0.9 0.9 0.9],'Callback',@reset_Callback);
status = uicontrol('Style','text','String','','Units','pixels','Position',[714 235 130 20],'HorizontalAlignment','left');
gui.Visible = 'on';
function doB_Callback(src,event)
output_area.String = [input_area1.String,input_area2.String];
status.String = 'Done';
end
function getB_Callback(src,event)
input_area1.String = [input_area2.String,output_area.String];
status.String = 'Done';
end
function reset_Callback(src,event)
input_area1.String = '';
input_area2.String = '';
output_area.String = '';
end
end

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by