Making GUI with sub-elements resizable in a quick way
Mostrar comentarios más antiguos
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?
Respuesta aceptada
Más respuestas (2)
per isakson
el 6 de Jun. de 2014
Editada: per isakson
el 6 de Jun. de 2014
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 comentario
chlor thanks
el 3 de Ag. de 2016
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
el 6 de Jun. de 2014
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 comentarios
Matt J
el 6 de Jun. de 2014
Image Analyst
el 11 de Jun. de 2014
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.
Categorías
Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!