| 查看: 1083 | 回复: 1 | |||
[求助]
MATLAB gui 下拉菜单的实现
|
|
求助! 现在有三个单选按钮,想改成一个下拉菜单实现。 单选按钮部分的程序: Rs1=uicontrol(FigureHandle,'Style','radio','unit','pixels',... 'Position',[TextXP(2),TextYP(2),140,TextHeight],... 'String','situation1', 'Value',InputData.Type(1),'Tag','Type1',... 'CallBack',['set(findobj(''Tag'',''Type1''),''Value'',1);'... 'set(findobj(''Tag'',''Type2''),''Value'',0);'... 'set(findobj(''Tag'',''Type3''),''Value'',0);'],... 'fontsize',12,'BackgroundColor', BackColor{2}); Rs2=uicontrol(FigureHandle,'Style','radio','unit','pixels',... 'Position',[TextXP(2),TextYP(2),140,TextHeight],... 'String','situation2', 'Value',InputData.Type(2),'Tag','Type2',... 'CallBack',['set(findobj(''Tag'',''Type1''),''Value'',1);'... 'set(findobj(''Tag'',''Type2''),''Value'',0);'... 'set(findobj(''Tag'',''Type3''),''Value'',0);'],... 'fontsize',12,'BackgroundColor', BackColor{2}); Rs2=...(类似) 改成: Rs1=uicontrol(FigureHandle,'Style','popup','unit','pixels',... 'Position',[TextXP(2),TextYP(2),100,TextHeight],... 'String','situation2|situation2|situation3',... 'CallBack',@SetTag,'fontsize',11,'BackgroundColor', BackColor{3}); 定义的SetTag函数: function SetTag(h,event,data) % Called when user activates popup menu val = get(h,'Value'); if val==1 set(findobj('Tag','Type1'),'Value',1); set(findobj('Tag','Type2'),'Value',0); set(findobj('Tag','Type3'),'Value',0); elseif val==2 set(findobj('Tag','Type1'),'Value',0); set(findobj('Tag','Type2'),'Value',1); set(findobj('Tag','Type3'),'Value',0); elseif val==3 set(findobj('Tag','Type1'),'Value',0); set(findobj('Tag','Type2'),'Value',0); set(findobj('Tag','Type3'),'Value',1); end 现在能显示下拉菜单,也可以选择,但是Value部分赋值给InputData.Type该怎么弄,不会写啊,求教! |
» 猜你喜欢
师弟论文见刊大半年才想起来申请专利,还能抢救一下吗?
已经有3人回复
上海工程技术大学 激光智能制造课题组 2027级博士研究生招生
已经有5人回复
课题组招2027级博士 上海工程技术大学 激光智能制造方向
已经有5人回复
有机合成以后会不会被AI改变?做科研的虫友怎么看
已经有8人回复
求合成方法
已经有7人回复
现代”学阀”该如何界定
已经有12人回复
我的奶奶
已经有3人回复
2楼2015-09-17 12:45:23










回复此楼