How do I make my GUI's look similiar on several platforms?

11 views (last 30 days)
I created a GUI on a PC and the labels on the controls don't fit completely when using it on a MAC.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 19 Feb 2021
Edited: MathWorks Support Team on 19 Feb 2021
The MATLAB Documentation has a page about how to design GUIs for cross-platform compatibility. Please see the following link:
There are two reasons why Graphical User Interfaces (GUI's) appear differently on different platforms.
One reason is that MATLAB uses the native definition of what a uicontrol (a pushbutton, radio button, etc.) should look like. MATLAB GUIs on a Windows machine will use Windows uicontrols, while the same GUI on a Linux or UNIX machine will use the Linux or UNIX definition of the uicontrols. These definitions may differ in appearance.
The second reason for the different appearances is the 'Units' property. To ensure a similiar appearance on all platforms, we suggest you use 'character' for the Units properties of your handle graphics objects. This is especially important if the fonts in your GUI are causing problems in the layout.
Since the default font might be different sizes on different platforms, characters units allow you to lay out your GUI to look the same regardless of differences in the sizes of default fonts (without having to add lots of extra space around your strings). However, if your GUI looks good using the default font and character units on the platform you programmed it on, it should look just as good on all other platforms, regardless of the size of the default font. So in general:
1) Don't hard-code a font into your GUI, but instead use the default font.
and
2) Use 'character' units in your figure's layout.
For more information regarding this and other HG properties, please see the Handle Graphics Property Browser found here:
  3 Comments
Cam Salzberger
Cam Salzberger on 15 Apr 2016
Edited: MathWorks Support Team on 19 Jan 2021
I would say that this answer is accurate as best-practices for a good starting point, even on recent versions of MATLAB. If all (and I mean all) UI elements use character units, then theoretically the entire GUI should scale with respect to the default character width.
I personally prefer to use normalized units when I make GUIs, because I usually allow them to be resizeable. The issue can come up when the character size on another system is larger than on the one I created the GUI on. Then labels on buttons and other components can expand past the component borders. Usually just building in a little extra room is sufficient to account for this though.
There can also be issues introduced if a GUI gets near to screen-size. A GUI may fit on the screen that it is developed on, but if it opens on a different system and is larger than the screen, it will be forced to be smaller by the operating system. This is one other reason that I like using normalized units.
Eric, I would suggest opening the GUI in GUIDE, and then resaving it with a different filename. Even doing this on the system it was originally built on can sometimes be enough to resolve any strange UI element placement issues. If that does not work, I would suggest contacting MathWorks Technical Support.
Walter Roberson
Walter Roberson on 15 Jun 2017
"So why 'characters' over 'normalized'?"
When a line plot or a patch or surface or image is made smaller, people can often tolerate that. Even a "thumbnail" of a plot can be useful. However, when text is reduced below 6 points, people can no longer read it and it becomes useless; 6 points itself is marginal, usually being a struggle (People can often read 8 point text through.)
Therefore in order to keep GUI usable, it is important that text elements not be reduced too much. Reducing an image by half from 1200 pixels to 600 pixels still gets you a very usable image, but reducing text by half from 10 point to 5 point (a proportional change) is not acceptable. Therefore it makes more sense to worry about characters than about relative proportions for other things.

Sign in to comment.

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Products


Release

R2009a

Community Treasure Hunt

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

Start Hunting!