GUI滚动条错误

时间:2014-01-29 07:15:29

标签: matlab user-interface

我正在尝试使用嵌套面板在GUI中创建滚动列表。但是,每当我尝试在GUI中移动滚动条时,都会收到此错误:

  

???使用==>时出错PyroGUI>滑块输入参数太多。
  ???   评估uicontrol回调时出错

这是我的代码:

screensize=get(0,'ScreenSize');

handles.fig=figure('Position',[100 100 screensize(3)-150 screensize(4)-150]);


handles.hpanel=uipanel(handles.fig,'Position',[0.005 0.01 0.99 0.99],'Title','Panel');
handles.hsp = uipanel('Parent',handles.hpanel,'Title','Subpanel','FontSize',12,...
              'Position',[.025 .05 .3 .935]);

handles.hpop = uicontrol('Style', 'slider',...
       'Position', [20 30 20 700],...
       'Min',1,'Max',700,'Value',700,...
       'callback', {@slider,handles.hsp});

handles.pos=get(handles.hpanel,'Position');   
function slider()
        slidervalue=get(handles.hpop,'Value');
        set(handles.hpanel,'Position',[handles.pos(1) handles.pos(2)-slidervalue+1 handles.pos(3) handles.pos(4)]);
    end

关于可能导致这种情况的任何想法?

1 个答案:

答案 0 :(得分:1)

如果为uicontrol提供回调函数,它总是需要两个这样的输入参数(即使你不需要它们)

function slider(hobj, evnt)
        slidervalue=get(handles.hpop,'Value');
        set(handles.hpanel,'Position',[handles.pos(1) handles.pos(2)-slidervalue+1 handles.pos(3) handles.pos(4)]);
    end

修改:点击此处http://www.mathworks.de/de/help/matlab/creating_guis/examples-programming-gui-components.html