How can I move the position of my GUI on the screen from the default?

조회 수: 30 (최근 30일)
hana
hana 2013년 2월 14일
편집: UTHARA BALRAJ 2019년 12월 5일
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
Oscar Raya i Casanova 2019년 9월 20일
Your second option worked nice on matlab app designer (first one didn't work).
UTHARA BALRAJ
UTHARA BALRAJ 2019년 12월 5일
편집: UTHARA BALRAJ 2019년 12월 5일
Where to put that code in App Designer?

댓글을 달려면 로그인하십시오.

채택된 답변

hana
hana 2013년 2월 15일
the issue was resolved by restarting MATLAB!! There might have been a bug, but my guess is that had something to do with switching back and fort btw external and default monitor of my machine. I reset the position data in the position property of the main Figure of the gui and it worked after trying the same thing over and over!!
thanks for all your suggestions

추가 답변 (4개)

David Kusnirak
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

hana
hana 2013년 2월 15일
편집: hana 2013년 2월 15일
Thank you, but normalizing units didn't work either.

Image Analyst
Image Analyst 2013년 2월 15일
Make sure the main figure's WindowStyle property is normal, not modal or docked.

Sean de Wolski
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?

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by