Create GUI figures which scale position and size based on resolution
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello, I have a program which first has one GUI which has a button which is pushed to call three other GUIs. I want these four GUIs to have a set layout, in that the initial GUI occupies ~1/4 of the screen on the left side, two GUIs stacked upon each other in the middle of the screen, then the final GUI on the right side. I have changed the positions for each and made it so that this layout is present using my laptop at its native screen resolution. The issue, however, is that I plan to give the program to others, and when I change the screen resolution of my laptop to one with a different aspect ratio of a smaller size, the distance between GUIs and their size remains the same. This pushes the last, right-most GUI partially off the screen. I have set all units, including font units and position units, to 'normalized' for all four GUI windows. Is there something else I have to do to have the window size scale automatically?
Thanks, Ak
8 Kommentare
Adam
am 18 Jul. 2018
My second monitor is just considered as an extension of the first in terms of size - e.g. screen resolution returns 1920 as my lateral screen size. If I position a figure at 2100 it puts it on the second monitor.
You can use
get( groot, 'MonitorPositions' )
if you want to make full use of the real estate available on a given machine, although this would involve having to do different things depending how many monitors there are. The above command gives me a 2x4 output for my monitors so taking the size of the first dimension of this result will tell you how many monitors there are, though there may be a single call function that also gives you this that I am not aware of.
As an aside, if you want to nosey into what is available (which I always do!)
get( groot )
will give a list of all the values you can query from groot.
Akzeptierte Antwort
Jan
am 18 Jul. 2018
Fig1H = figure('Units', 'normalized', 'Position', [0, 0, 0.25, 1], 'Name', 'Figure 1');
Fig2H = figure('Units', 'normalized', 'Position', [0.25, 0.5, 0.5, 0.5], 'Name', 'Figure 2');
Fig3H = figure('Units', 'normalized', 'Position', [0.25, 0, 0.5, 0.5], 'Name', 'Figure 3');
Fig4H = figure('Units', 'normalized', 'Position', [0.75, 0, 0.25, 1], 'Name', 'Figure 4');
This creates two figures with 1/4 of the width and the full height on the left and right, and two figures on top of each other at the center. Does this help already?
11 Kommentare
Rik
am 20 Jul. 2018
@Jan, not entirely: try it with you taskbar on the side instead of top or bottom. I also have my IM program docked on the other side, so maximizing is the only way to find out how much screen real estate you have to work with. In my case the position is [0.0431 0 0.8243 0.9144] for a maximized window.
OCDER
am 20 Jul. 2018
Matlab 2018a now has the WindowState property of a figure to allow users to maximize a figure according to the OS behavior.
set(FigH(1), 'WindowState', 'maximized')
ScreenPosWithoutTaskbar = get(FigH(1), 'Position');
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating, Deleting, and Querying Graphics Objects finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!