How to resize the GUI window developed in GUIDE?
2 次查看(过去 30 天)
显示 更早的评论
I have written a code for resizing the GUI window.
The function sets a default value to the entire figure and then adjusts itself according to the user's choice to expand or contrac the window.
There is something wrong with the code as I am unable to see the code running.
Following is the code:
function figure_electricity_ResizeFcn(hObject, eventdata, handles)
% hObject handle to figure_electricity (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if ~isfield(handles,'pos_figure_electricity')
% Store positions of uipanels and other GUI objects for resize functions
handles.pos_figure_electricity = get(handles.figure_electricity,'Position');
handles.pos_panel_e = get(handles.uipanel_e,'Position');
handles.pos_panel_i=get(handles.uipanel_i,'Position');
handles.pos_ok = get(handles.Ok_button,'Position');
handles.pos_cancel = get(handles.Cancel_Button,'Position');
handles.colwidth_eptable = get(handles.eptable,'ColumnWidth');
% Update handles structure
guidata(hObject, handles);
end
electricitypos = get(handles.figure_electricity,'Position');
pos_panel_e = handles.pos_panel_e;
if electricitypos(3) >= 640 && electricitypos(4) >= 480
% Scale uipanel '' normalized
pos_panel_e([1 3]) = (electricitypos(3)/640)*pos_panel_e([1 3]);
pos_panel_e([2 4]) = (electricitypos(4)/480)*pos_panel_e([2 4]);
set(handles.uipanel_e,'Position',pos_panel_e);
else
if electricitypos(3) < 640
electricitypos(3) = 640;
end
if electricitypos(4) < 480
electricitypos(4) = 480;
end
pos_panel_e([1 3]) = (electricitypos(3)/640)*pos_panel_e([1 3]);
pos_panel_e([2 4]) = (electricitypos(4)/480)*pos_panel_e([2 4]);
electricitypos([1 2]) = handles.pos_figure_electricity([1 2]);
pause(0.1)
set(handles.figure_electricity,'Position',electricitypos);
set(handles.uipanel_e,'Position',pos_panel_e);
end
0 个评论
回答(1 个)
Image Analyst
2014-2-14
Try this:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
Adjust the numbers between 0 and 1 until you get what you want.
0 个评论
另请参阅
类别
在 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!