Hot to change the settings of multiple gui components at the same time
5 次查看(过去 30 天)
显示 更早的评论
Hello,
I have a programmatically written gui. Their units are in pixels. After writing everything in pixels, I wanted to set all the units to normalized. I don't want to do it one by one. Do you know how I can set to normalized for multiple handles at the same time?
Thank you,
Emre
0 个评论
采纳的回答
Sean de Wolski
2012-8-10
Okay:
handles = struct('h1',pi,'h2',3,'edit1',17); %exmaple handles
set(cell2mat(struct2cell(handles)),'somefield',some_value);
3 个评论
Sean de Wolski
2012-8-10
You can't have the '.' in the field name of a struct. It looks lik eyou probably want:
tobenormalized=struct('text',handles.text);
更多回答(2 个)
Matt Fig
2012-8-10
Pass in a vector of the handles:
u(1) = uicontrol;
u(2) = uicontrol;
u(3) = uicontrol;
set(u,'units','norm')
5 个评论
Addy
2018-5-9
In that case, something like this would be easiest of all!
set(findall(gcf,'units','pix'),'units','norm')
OMG. Thank you very much for this. I finally found this gold after 5 hours of madness :^)
Kevin Phung
2019-3-25
编辑:Kevin Phung
2019-3-25
ditto that!! That's one beautiful line. Thanks @Loginatorist
另请参阅
类别
在 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!