How can I move the position of my GUI on the screen from the default?
10 次查看(过去 30 天)
显示 更早的评论
I have a GUIDE gui made with MATLAB R2011a. Non of the following techniques has worked to move the gui on the screen:
1)use of
movegui('center')
in the main Figure's CreateFcn or the gui's Opening function
2) use of this code in Opening function:
%pixels
set( handles.figure_main, ...
'Units', 'pixels' );
%get your display size
screenSize = get(0, 'ScreenSize');
%calculate the center of the display
position = get( handles.figure_main, ...
'Position' );
position(1) = (screenSize(3)-position(3))/2;
position(2) = (screenSize(4)-position(4))/2;
%center the window
set( handles.figure_main, ...
'Position', position );
3)or even simple commands of:
set(handles.figure_main,'Units', 'pixels');
set(handles.figure_main,'Position', [900 39 912 600]);
Any help is appreciated
2 个评论
Oscar Raya i Casanova
2019-9-20
Your second option worked nice on matlab app designer (first one didn't work).
采纳的回答
更多回答(4 个)
David Kusnirak
2013-2-14
hi,
try to change units from pixels to normalized
for example
set(handles.figure_main,'Units', 'normalized');
set(handles.figure_main,'Position', [0.5 0.5 0.1 0.1]);
if it works update the position vector to fit your requirments
0 个评论
Image Analyst
2013-2-15
Make sure the main figure's WindowStyle property is normal, not modal or docked.
0 个评论
Sean de Wolski
2013-2-15
编辑:Sean de Wolski
2013-2-15
What about part #2 from what you have above in the first part of the OutputFcn?
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!