This is Part 2 of 3 Pick of the Week entries on GUIs, written by guest blogger Jiro
In Part 1, I talked about how I use the ResizeFcn property of the figure to adjust the layout of my UI controls. Well, I'm always looking for easier ways to do layouts.
Jerome Briot wrote these utility tools SETPOS and GETPOS that give you more flexibility in defining the positions of objects. With these, you can provide individual units for the
four numbers that define the Position property:
% Use "normalized" for X and Width.
% Use "pixels" for Y and Height.
setpos(h,'0.25nz 100px 0.5nz 300px');
There are other nice features, such as incrementing by certain values:
% Increase the width by 200 pixels
setpos(h,'# # +200px #');
This function will allow me to do precise positioning of UIs with fewer lines of code. Thanks Jerome! Next week, I will introduce
a different tool that assists in the overal GUI design. Stay tuned for Part 3...
Comments?
Tell us what you think about when you are laying out your GUI components. Is it readability? Or is it the level of informational
content?
Written by Jiro Doke, Senior Applications Engineer, The MathWorks, Inc.
댓글
댓글을 남기려면 링크 를 클릭하여 MathWorks 계정에 로그인하거나 계정을 새로 만드십시오.