How to resize the GUI window developed in GUIDE?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Image Analyst
am 14 Feb. 2014
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 Kommentare
Siehe auch
Kategorien
Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!