Changing properties of menu

조회 수: 1 (최근 30일)
David Koenig
David Koenig 2012년 2월 24일
I am trying to increase the font size in the menu. In the script below I am able to do that but it also increases the font size in subsequent plots even though I do reset the font size within the loop. Also, if I click on "quit" I get out of the loop and the final plot has the desired smaller font size. Finally, I always get "MENU: No menu items to choose from." whenever I run this script. Therefore, is it possible to change the font size of the menu entries and then change it back for any plots to follow...and how do I get rid of the "MENU: No menu items to choose from." messages?
Here is the test script:
close all; clear;
ii=1;
while ii==1
fh=menu;
set(fh,'ScreenPixelsPerInch', [150]);
kk=menu('Choose','quit','continue');
set(menu,'ScreenPixelsPerInch', [96]);
fh=figure;
plot(1:10,1:10),grid
title('Test Plot')
if kk==1
break
end
end
Thanks,
Dave

채택된 답변

Sean de Wolski
Sean de Wolski 2012년 2월 24일
This line causes the "no items to choose from warning":
fh=menu;
The reason this is working at all is because you are changing the root property (i.e. MATLAB base property) screenpixelsperinch
This happens because
fh = menu
returns 0, the root identifier. To get the behavior you want:
ii=1;
while ii==1
oldSPPI = get(0,'screenpixelsperinch'); %store old one
set(0,'screenpixelsperinch',200); %increase - will affect everything
kk = menu('choose','me','no me!','go home it''s Friday!');
set(0,'screenpixelsperinch',oldSPPI); %restore
figure;
plot(1:10,1:10),grid
title('Test Plot')
if kk==1
break
end
end
Thus the reason it affects everything, is, well you're changing MATLAB's settings.
If this functionality is really important to you, I suggest you write your own menu function and increase the fontsize of the uicontrols manually. See Matt Fig's demos:
Post a new question if you choose to go this route and need assistance!

추가 답변 (0개)

카테고리

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