필터 지우기
필터 지우기

How to resize a GUI (which contains many items)

조회 수: 39 (최근 30일)
Diana Acreala
Diana Acreala 2012년 1월 3일
댓글: Javier Gutierrez 2018년 2월 8일
Hello
I'm coming with a question about resizing a GUI in Matlab. I found the following examples on the site: "Panel" and "An Address Book Reader (GUIDE)" but it's not behaving as it should. For example the text on the buttons does not scale (I can't see the entire text when making the GUI small). About the text it is said this:"You can enable text in controls to resize automatically by setting the component's fontUnits to normalized, without the need for a ResizeFcn." and this is not working also. What about dealing with components like:edit text, table, axes, listbox, pop-up menu? Is something special about these when we talk about resizing?
I would be very grateful if you could help me. Thank you in advance! Diana A.
  댓글 수: 1
chlor thanks
chlor thanks 2016년 8월 3일
Diana, this is exactly what I am trying to do...have you figure out a way yet?

댓글을 달려면 로그인하십시오.

답변 (5개)

Fabricio Castro
Fabricio Castro 2017년 11월 11일
Hi Diana Acreala,
This kind of problem is easily solved in python, but in matlab you need to create your own SizeChangedFcn to force the width and height of UI components to be fixed while the size of the parent window become larger or smaller.
I'm appending a rar file composed by two .m files. One script hold the code about the generation of the GUI and the other script is the edited SizeChangedFcn that is called by the GUI.
Hope I have helped you.

Robert Cumming
Robert Cumming 2012년 1월 3일
d = dialog ( 'windowstyle', 'normal', 'resize', 'on' );
uicontrol ( 'parent', d, 'style', 'pushbutton', 'units', 'normalized', 'position', [0.1 0.1 0.5 0.5], 'string', 'test', 'fontunits', 'normalized', 'fontsize', 0.1 );
  댓글 수: 3
Robert Cumming
Robert Cumming 2012년 1월 3일
As I dont know your code... so I cant say.
Is your gui created in GUIDE? or like my example?
Sarah Ghosh
Sarah Ghosh 2013년 7월 10일
Problem with Robert Cumming's Answer.....
But if the fontsize is changed to 0.7 (for example), then the text on the pushbutton becomes pretty big. Then on resizing the whole GUI window, when the button becomes smaller, the text does not. It is displayed as t...
How to set the text such that, when the button becomes smaller, the text becomes proportionally smaller.
Thanks in advance

댓글을 달려면 로그인하십시오.


Diana Acreala
Diana Acreala 2012년 1월 6일
My gui is created in GUIDE. Now I found another example in Matlab help. I searched in HELP after resize and the third thing (starting with the first top) found called: 'Figure Resize Functions' contains the example that helps me.
This is actually what I want but it's very complicated. There is a lot of math and I really can't get the algorithm.
The gui in this example is very simple..I have a lot of elements on my gui and at this moment it's terrible for me to resolve this problem.
Would be very simple if I would understand the calculation of the coordinates.. what do you think? Is there an algorithm or the math is made after testing?
Thank you!
  댓글 수: 1
Robert Cumming
Robert Cumming 2012년 1월 6일
I dont use guide, and I would advise you learn how to create a GUI wihtout it - it will benefit you in the long run.
The idea however is the same - you need to set all your preoperties to have units which are normalized - then when you resize they will be resize automatically.

댓글을 달려면 로그인하십시오.


Shubham
Shubham 2013년 4월 4일

DjeKKo_O
DjeKKo_O 2016년 9월 6일
Hi everybody,
I have the same problem, using GUIDE. I want to set all the elements Units and FontUnits to 'normalized'. It appears to work correctly for all kind of elements EXCEPT : 1/ for the images inserted in buttons => I handled it by writing a specific code in the Resize function 2/ for the FontUnits of panels or button groups => I don't understand what GUIDE is doing....
In the last case indeed, when I set panels or buton groups FontUnits to 'normalized', GUIDE automatically turns the FontSize attribute to '-1'. It is then impossible to change it. And when running the program, the font is still not affected by resizing...
Any clue to explain this unusual GUIDE's behaviour or to solve it by some lines within the resize function would be truly welcome.
Thanks,
Djekko
  댓글 수: 1
Javier Gutierrez
Javier Gutierrez 2018년 2월 8일
Djekko could you share the code to resize pictures in buttons please?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by