How can I change the default units in GUIDE

조회 수: 16 (최근 30일)
Yuval Cohen
Yuval Cohen 2014년 4월 10일
답변: Robert Thomas 2022년 9월 30일
Hello, I use GUIDE for many of my GUIs. I like using 'pixels' for the figure and all uicontrols. Unfortunately, the default units are 'characters' and I have to manually change the unit value for every new uicontrol I add.
Is there a way to change the default units?
Thank you, Yuval

답변 (4개)

Image Analyst
Image Analyst 2014년 4월 17일
You can't change the default as far as I know. You need to set up each one. However they don't need to be done one at a time in the Property Inspector, and you don't need to write something into every CreateFcn. You can set them all as a group (well almost all). What you can do is to drag a box around all the controls on your figure to select all of them. Then double-click on any one of them to bring up the Property Inspector. It will list only those properties that apply to all of them, and some will be missing because some controls don't have certain properties. Fortunately "Units" is one of those that will be shown. You can change the units to pixels for all the controls that you have selected, then close the property inspector. The only ones it won't apply to are those controls that are located inside a panel (group box). For those you have to set them one at a time.

nl2605
nl2605 2014년 4월 17일
In the CreateFcn you can change the units as you want them to be. But yes, you will have to write it in every CreateFcn of your figure components.

Sean de Wolski
Sean de Wolski 2014년 4월 17일
In general, you can do this if you were making programmatic UIs. However, GUIDE sets its own defaults that can't be changed to my knowledge.
With a regular figure:
hFig = figure;
set(hFig,'Defaultuicontrolunits','pixels')
set(hFig,'Defaultaxesunits','pixels')
set(hFig,'Defaultuipanelunits','pixels')
I would recommend IA's approach. You can also right click a graphics component in GUIDE to make a copy of it. That way you change the properties once, right click and drag to get an identical object.
  댓글 수: 1
Image Analyst
Image Analyst 2014년 4월 17일
Neat trick (right click and drag). I was always using control c, control v to create a copy of a control.

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


Robert Thomas
Robert Thomas 2022년 9월 30일
majority of students find to be quite uninteresting and challenging It is because they place a greater emphasis on raising their grades than on developing their creativity It is true that you must adhere to the instructions provided by your professor sad story ideas There are some times when in life things do not go the way we want We have no choice but to accept them as they are or deal with them.

카테고리

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