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

10 次查看(过去 30 天)
I created a GUI on a PC and the labels on the controls don't fit completely when using it on a MAC.

采纳的回答

MathWorks Support Team
编辑:MathWorks Support Team 2021-2-19
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 个评论
Cam Salzberger
Cam Salzberger 2016-4-15
编辑:MathWorks Support Team 2021-1-19
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 2017-6-15
"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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

产品


版本

R2009a

Community Treasure Hunt

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

Start Hunting!

Translated by