GUIDE changes my figure size and displays wrong information

I have a 980 x 720 pixels GUI figure. I need to modify it with GUIDE, but when I open it on my laptop with 1366 x 768 screen resolution I can't see the entire figure; there is a vertical scrolling bar (because the screen resolution is less than the height of the figure), but if I scroll the window I can't see my fig from top to the end.
On the property inspector the figure height is not 702 instead of 720 (??). If I change 702 to 720 the "Position" field on the rigth bottom of the window displays the new value, but on the Property Inspector the new value is again forced to 702!
Scrolling the vertical bar, I checked that the new height is 720, but when I save the figure, GUIDE automatically re-change the height to 702, loosing the 18 pixels height difference.
I guess that this behavior is related to the laptop screen resolution, but It's not acceptable, because if I want to create or modify a figure setting dimensions (to use on another pc with higher resolution) higher than my laptop's screen, I can't.
Moreover, the GUIDE accepts the new dimension but when I save the figure it discards!! See below attached picture with conflicting height values.
How can I do?
Thanks

2 Comments

Is there a particular reason you're using GUIDE? You will have so many more options if you ditch it, especially in cases like this.
See also this thread.
thanks, Rik.
I have lot of figures created with GUIDE and I'v never had problems. I know in future I shall use app designer, but now I need to use the gui builder. Which options do you mean?
The problem is that GUIDE is still available, so I guess that it must work correctly. Could you help me?
I need an explanation about this strange behaviour

Sign in to comment.

 Accepted Answer

I would set the position property in code. You can also do that by putting it in the startup function. You could even first do a check on the resolution of the screen.
OriginalUnits=get(0,'units');
set(0,'Units','Pixels')
ScreenSize=get(0,'ScreenSize');
set(0,'Units',OriginalUnits)
disp(ScreenSize)
1 1 1920 1200
if ScreenSize(4)<750
warning('your vertical screen resolution is too low for this app to work properly')
% Set the figure height to something small for your testing
else
warning('your vertical screen resolution is large enough')
% Set the figure height to what you actually need it to be
end
Warning: your vertical screen resolution is large enough

4 Comments

Thank you Rik, but I don't like this solution, because if I have lots of figures with different size, I should know ALL the figure dimensions and check if there is a figure larger than my screen resolution.
The main problem is that if you want to modify a figure larger than the screen resolution, you can't, and GUIDE doesn't tell you...
I don't want to resize my figure to the screen resolution, because it's not correct. Obviously I can't display the figure on my laptop, but I want to modify it without unexpected size cutting.
We disagree on the main problem.
I see the use of GUIDE as the main problem. Every GUI that has a specific minimum intended size in pixels, should determine whethere it is running on a large enough screen when it starts. The fact you have lots of figures doesn't change that.
I agree that there should be some sort of warning when you load a fig file and Matlab adjusts the sizes. But remember: that is only a problem because you used GUIDE and split your GUI in two (the m file and fig file). If you only work in code, you could modify the positions and sizes of buttons without any screen at all and the screen resolution of your laptop would not affect the size of the GUI on other computers.
One additional thing (more of a personal preference): I always write GUIs with relative positions. On large screens they will look strange, and on small screens they will be cramped, but no functionality is lost or gained.
I use GUIDE for figures with a lot of objects, because it takes long time to do it programmatically, expecially when you have to decide the objects position in the figure. Of course, for little figures I prefer build them directly with code.
Thank you for your suggestions
I tend to find myself in one of these two situations:
  1. I have several uicontrol elements that can all use the same callback, as long as I give them a unique tag.
  2. I have components that each require their own callback.
In the first case I write a function that will create a grid of components. In the second case, each component requires manual action anyways.
Your GUI is apparently fundamentally different, although you might want to sit down and think whether it really is not possible to categorize your components like this.
I often use GUIDE, but only to get a feel for how it will all fit together, like a glorified MS Paint.
I suspect it will not be worth it for you to use the 'generate code' option that GUIDE allows, but you could have a try.

Sign in to comment.

More Answers (0)

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Products

Release

R2020b

Asked:

on 25 Aug 2022

Commented:

Rik
on 26 Aug 2022

Community Treasure Hunt

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

Start Hunting!