您的位置:首页 > 产品设计 > UI/UE

gui设计中的enable问题

2016-03-14 11:12 447 查看
screen=get(0,'ScreenSize'); %电脑屏幕尺寸

W=screen(3);H=screen(4); %获得整个电脑的长宽

figure('Color',[1 1 1],'Position',[0.2*H,0.2*H,0.5*H,0.3*H],'Name','图形演示系统', ...

'NumberTitle','off','MenuBar','none');

hplot=uimenu(gcf,'Label','&Plot');

uimenu(hplot,'Label','Sine Wave','Callback',['t=-pi:pi/20:pi;','plot(t,sin(t));','set(hgon,''Enable'',''on'');', ...

'set(hgoff,''Enable'',''on'');','set(hbon,''Enable'',''on'');', ...

'set(hboff,''Enable'',''on'');']); %整个callback函数用[]括起来

uimenu(hplot,'Label','Cosine Wave','Callback',['t=-pi:pi/20:pi;','plot(t,cos(t));','set(hgon,''Enable'',''on'');', ...

'set(hgoff,''Enable'',''on'');','set(hbon,''Enable'',''on'');', ...

'set(hboff,''Enable'',''on'');']);

hoption=uimenu(gcf,'Label','&Option');

hgon=uimenu(hoption,'Label','&Grid on','Callback','grid on','Enable','off'); %enable表示此功能是否使能

hgoff=uimenu(hoption,'Label','&Grid off','Callback','grid off','Enable','off');

hbon=uimenu(hoption,'Label','&Box on','separator','on','Callback','box on','Enable','on'); %separator设置分隔线

hboff=uimenu(hoption,'Label','&Box off','Callback','box off','Enable','on');

hwincor=uimenu(hoption,'Label','&Window Color');

uimenu(hwincor,'Label','&Blue','Accelerator','b','Callback','set(gcf,''Color'',''b'');'); %Accelerator设置快捷键

uimenu(hwincor,'Label','&Yellow','Callback','set(gcf,''Color'',''y'');');

uimenu(hwincor,'Label','&White','Callback','set(gcf,''Color'',''w'');');

hquit=uimenu(gcf,'Label','&Quit');

uimenu(hquit,'Label','&退出','Callback','close(gcf)');
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: