Making GUI with sub-elements resizable in a quick way
古いコメントを表示
When developing a GUI in guide, there is a global GUIDE option that let's you make the GUI resizable in a way that all sub-elements resize proprtionately with the figure.
However, I am given a programmatically generated GUI and I would like to modify the mfile so that it is resizable in the same way. Is there a quick way to do this, i.e., by modifying a single property of the parent figure, or do I have to write a ResizeFcn callback that manually alters the size/position of the sub-elements one by one?
採用された回答
その他の回答 (2 件)
per isakson
2014 年 6 月 6 日
編集済み: per isakson
2014 年 6 月 6 日
Based on a simple experiment with R2013a, I think this will do the trick
h = findobj( fh, '-property', 'Units' );
set( h, 'Units', 'Normalized' )
where fh is the handle of the GUI (figure).
I'm not sure about pro/cons regarding setting the unit property of the figure itself. I guess it doesn't hurt.
BTW, you might need to replace findobj by findall
1 件のコメント
chlor thanks
2016 年 8 月 3 日
Hi per, I want to try your code to resize the static text in my text box made in GUIDE, is this possible? Is so, should I put handles.statictext instead of fh in the code and where shall I insert this code? Thanks!
Image Analyst
2014 年 6 月 6 日
You can programmatically resize your GUI like this:
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
You can also use position instead of outerposition and the array is [left, top, width, height] and has values ranging from 0 to 1 (which is the fraction of the total screen size), so pick whatever values you want.
2 件のコメント
Matt J
2014 年 6 月 6 日
Image Analyst
2014 年 6 月 11 日
No it does not, but that doesn't matter. The figure will scale, but if the units of the other controls are all "characters" then they won't scale and will appear in the upper left corner. If you want them to scale/resize also, then set the units of all the controls to normalized. It looks like per's code should do that.
カテゴリ
ヘルプ センター および File Exchange で Creating, Deleting, and Querying Graphics Objects についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!