【问题标题】:matlab design the uipanelmatlab设计uipanel
【发布时间】:2012-10-11 11:49:07
【问题描述】:

我想显示图像(文件路径)和下方以放置单元格。

不幸的是,图像消失了。 这是带有图像的 GUI。我希望黄色单元格位于图像下方。

这是我更改后的 gui:

hFig = figure('Name','Step 3 of 4: Choose data for each image','Menubar','none', 'Resize','off', ...
    'WindowStyle','modal', 'Position',[300 300 1150 500]);
set(gcf,'NumberTitle','off')
movegui(hFig, 'center');



%# top/bottom panels
S.fh = uipanel('Parent',hFig, 'BorderType','none', ...
    'Units','normalized', 'Position',[0 0.002 1 0.28]);

Layout = GridLayout(S.fh, ...
'NumRows', 2, ...
'NumCols', 3, ...
'HGap', 10, ...
'VGap', 5, ...
'Margin', 10, ...
'CellMargin', 10, ...
'CellColor', 'y');


for RIdx = 1:Layout.NumRows
    for CIdx = 1:Layout.NumCols

        if (RIdx == 1)
           UIArgs = {'Style','text', 'String',choice{CIdx}};
        else
           UIArgs = {'Style','edit', 'String',''};
        end

        hFig = Layout.Cell(RIdx,CIdx);
        uicontrol(hFig, UIArgs{:});
    end
end


S.pb = uicontrol('style','pushbutton',...
             'units','pix',...
            'position',[380 20 180 30],...
            'string','Submit',...
            'callback',{@pb_call});


S.pc = uicontrol('style','pushbutton',...
             'units','pix',...
            'position',[580 20 180 30],...
            'string','change the image',...
            'callback',{@pc_call});

Update(Layout);

【问题讨论】:

  • 您不应将变量命名为内置 matlab 函数! (我指的是sum)。

标签: matlab position uicontrol


【解决方案1】:

如果你真的必须自己编程,有GridLayout FEX contribution

GridLayout 的灵感来自 GridBagLayout 管理器。它同样灵活,但更符合我的口味,而且它还需要更少的样板代码。

它肯定会减轻您的编程工作..

【讨论】:

  • 谢谢,但我输入时出错:GridLayoutDemo1 ??? “double”类型的输入参数的未定义函数或方法“GridLayout”。 ==> GridLayoutDemo1 在 13 时出现错误 Layout = GridLayout(Parent, ...
  • @AlonShmiel 您需要将 .m 文件的路径添加到 matlab 路径。为此,cd 到解压 GridLayout 的目录并输入 addpath(pwd)。然后 cd 到 Demo 并运行示例。
  • 谢谢!我成功地看到了这些例子。现在我正试图在我的项目中做这样的事情。我稍后会更新这个话题。谢谢!
  • @AlonShmiel 您只是复制了该示例,而没有尝试使其适应您的需求。我不会为你解决你的编程问题。我相信我对你的帮助已经足够了——在编写代码之前先尝试了解 GridLayout 的工作原理。你可以做到的:)
  • 好的,我试过了,正在尝试..如果我不成功,我稍后会更新我的主题..谢谢你的帮助:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-06-20
  • 2014-12-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多