您的位置:首页 > 编程语言 > MATLAB

matlab gui(三)对话框(文件打开/保存对话框,进度条)

2016-03-19 17:23 951 查看
%% 文件打开/保存
%uigetfile
uigetfile%默认获得(不是打开)文件对话框
doc uigetfile
%规定打开文件类型
uigetfile('*.m');
%输出参数的意义,可看上边的doc文件
[filename,path,sureORcancel]=uigetfile;
if(sureORcancel==1)
load(fullfile(filename,path));
end
uigetfile('*.m','实例','default.m');
%输入/保存文件
[a b c]=inputfile('*.m');

%% 颜色/字体设置对话框
uisetcolor
doc uisetcolor
c=uisetcolor([1 0 0])
h=plot(0:10);
c=uisetcolor(h);%将句柄加入,可以设置其代表的图形的颜色
b=uicontrol('Parent',gcf,'String','颜色值','Style','pushbutton', ...
'Callback','c=uisetcolor;set(b,''BackgroundColor'',c);');
%字体对话框
uisetfont(b);
%% 进度条
h=waitbar(0,'MySample');
get(h)%进度条由,坐标,{line,patch(面)},组成
get(get(h,'Children'));
ha=get(h,'Children');
%获得坐标轴子对象的子对象的内容
get(ha,'Children')
get(ans(1))
get(ans(2))

%获得个对象的内容就可改变其属性
hrand=waitbar(0.3,'颜色')
ha1=get(hrand,'Children');
hac=get(ha1,'Children');%ha1子对像的句柄列表
hapa=findall(hac,'Type','patch');
set(hapa,'Facecolor','k');
%% 普通对话框
dialog
h=dialog('name','aboutme', ...
'Position',[200 200 200 70]);
uicontrol('Style','pushbutton', ...
'Parent',h, ...
'Callback','plot(cos([0:0.1:6]))', ...
'String','确定', ...
'Units','Normalized', ...
'Position',[0.1 0.1 0.2 0.2]);
%错误/警告对话框
errordlg
warndlg
%% 输入对话框
name=inputdlg('input your name','MySample');
name=inputdlg({'input your name','age'},'MySample');
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  对话框 matlab gui