matlab的GUI怎么改字体,MATLAB:自动调整GUI组件/字体的大小

我在尝试制作MATLAB GUI时出现问题 automatically resizeable . 在彻底搜索网络寻求帮助和大量测试之后,我找不到解决方案 .

我一直在我的笔记本电脑( Screen size/resolution = 1366x768 )中开发一个简单的GUI(使用MATLAB,不使用GUIDE) . 一个非常简化的版本如下所示:

当我在台式计算机( Screen size/resolution = 1920x1080 )中运行相同的GUI时,它以下列方式显示:

考虑到屏幕尺寸( the code is provided in the bottom of this post ),GUI的尺寸会自动初始化 . 如您所见(红色箭头突出显示),组件之间的字体/间距不会自动调整大小,因此无论我们在何处运行文件,GUI都具有相同的方面 .

此外,当手动调整GUI大小时,会出现一些组件重叠:

用于此最小工作示例的代码如下:

function resizingGUIexample()

%% SET UP GUI

hdl.mainfig = figure();

% MANAGE FIGURE DIMENSIONS -------------------------------------------------------------------------------------

set(hdl.mainfig, 'Units', 'pixels');

dims = get(0, 'ScreenSize');

screenHeight = dims(4);

verticalMargins = floor((0.2*screenHeight)/2); % =10% of the screen height in each side

figureHeight = (0.8*screenHeight);

figureWidth = (0.8*screenHeight)*(4/3); % 4/3 Aspect Ratio

set(hdl.mainfig, 'Position', [0, verticalMargins, ...

figureWidth, figureHeight]);

movegui(hdl.mainfig,'center') % move GUI to center

color = get(hdl.mainfig,'Color'); % get background color to hide static texts, etc...

% AXES ---------------------------------------------------------------------------------------------------------

hdl.axes = axes('Parent', hdl.mainfig, ...

'Units', 'Normalized', ...

'Position', [0.295 0.05 0.63 0.63*(4/3)]);

% PUSH BUTTONS -------------------------------------------------------------------------------------------------

hdl.donePB = uicontrol(hdl.mainfig, ...

'Position', [0.85 0.91 0.075 0.075], ...

'String', 'Done', ...

'Fontsize', 16, ...

'Units', 'normalized', ...

'FontWeight', 'Bold');

% BUTTON GROUP and RADIO BUTTONS -------------------------------------------------------------------------------

hdl.buttonGroup = uibuttongroup('Parent', hdl.mainfig, ...

'FontSize', 16, ...

'FontWeight', 'Bold', ...

'BackgroundColor', color, ...

'Units', 'Normalized', ...

'Position', [0.05 0.69 0.2 0.2]);

titleBG = sprintf('Intensity\nNormalization');

set(hdl.buttonGroup, 'Title', titleBG);

hdl.VolumeRB = uicontrol(hdl.buttonGroup, ...

'Style', 'radiobutton', ...

'String', 'Volume', ...

'FontSize', 14, ...

'FontWeight', 'Bold', ...

'Units', 'normalized', ...

'BackgroundColor', color, ...

'Position', [0.1 0.67 0.8 0.3]);

hdl.SliceRB = uicontrol(hdl.buttonGroup, ...

'Style', 'radiobutton', ...

'String', 'Slice', ...

'FontSize', 14, ...

'FontWeight', 'Bold', ...

'Units', 'normalized', ...

'BackgroundColor', color, ...

'Position', [0.1 .25 0.8 0.3]);

end

关于如何解决这些问题的任何想法?

非常感谢提前 .

亲切的问候,

FábioNery

EDIT1: 我也非常愿意接受有关更好地初始化GUI维度和策略的建议,以避免在不同监视器/屏幕分辨率下运行GUI时出现问题 .

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值