matlab设计uipanel

时间:2012-10-11 11:49:08

标签: matlab position uicontrol

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

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

这是我改变之后的gui: enter image description here

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);

1 个答案:

答案 0 :(得分:1)

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

  

GridLayout受GridBagLayout经理的启发。它同样灵活,但更符合我的口味,也需要更少的样板代码。

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

相关问题