【问题标题】:GUI scrollbar errorGUI滚动条错误
【发布时间】:2014-01-29 07:15:28
【问题描述】:

我正在尝试使用嵌套面板在 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

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

【问题讨论】:

    标签: matlab user-interface


    【解决方案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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多