필터 지우기
필터 지우기

How to resize the GUI window developed in GUIDE?

조회 수: 1 (최근 30일)
Ashish
Ashish 2014년 2월 14일
답변: Image Analyst 2014년 2월 14일
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

답변 (1개)

Image Analyst
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.

카테고리

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