Info

この質問は閉じられています。 編集または回答するには再度開いてください。

I'm trying to set a GUI created by guide as resizeable using the GUI options dialog box. (shown below) When i turn this option on, a few pop up boxes do not work. Can someone help me out?

1 回表示 (過去 30 日間)
Gaurav Wadhwa
Gaurav Wadhwa 2018 年 9 月 25 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Is there an alternative route to resize a moderately complex gui ? ( 25+ GUI objects)
I'm not averse to writing a code for the resize function. I'm just not sure where such a function would be located, and if it would need any default parameters that make it compatible with GUIDE ?
  1 件のコメント
Adam
Adam 2018 年 9 月 26 日
I tend to use this toolbox for building complex UIs nowadays. It includes layouts which you can parameterise and will behave more sensibly when you resize your GUI.
I've never tried crowbarring them into an existing GUIDE GUI, but it is theoertically possible as it is all just a case of parenting of objects so you can reparent things from a GUIDE GUI to layouts in theory.

回答 (1 件)

Jan
Jan 2018 年 9 月 26 日
編集済み: Jan 2018 年 9 月 26 日
"Does not work" is not clear enough to understand, what happens or to suggest an improvement.
You can create a ResizeFcn easily. It is located in the M-file, where the other callbacks are found also. Using the handles of the uicontrol elements stored in the handles struct, it is not much work to assign new positions. A small example without using GUIDE:
% UNTESTED! Please debug by your own
function CreateGUI
handles.FigH = figure('SizeChangedFcn', @Resize, ...
'Position', [100, 100, 640, 480]);
handles.ButtonH = uicontrol('Style', 'PushButton', ...
'Position', [10, 440, 620, 30], ...
'Units', 'Pixels', 'String', 'Button');
guidata(handles.FigH, handles);
end
function Resize(FigH, EventData)
handles = guidata(FigH);
Pos = get(FigH, 'Position');
% Keep the button on the top and adjust the width:
set(handles.ButtonH, 'Position', [10, Pos(4) - 40, Pos(3) - 20, 30]);
end
By the way: "SizeChangedFcn" is the modern version of "ResizeFcn".
This works equivalently in GUIDE.

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by