필터 지우기
필터 지우기

Turn non-resizeable figure into resizeable figure?

조회 수: 13 (최근 30일)
Frank
Frank 2014년 11월 18일
댓글: Frank 2014년 11월 21일
Hi, I created a GUI with 2 axes, which has to be not resizeable. In addition, I would like to install a button to save the GUI as a resizeable figure. My attempt was to use copyobj to copy the figure into a new window and then set Resize to 'on', i.e.
newfig = copyobj (gcf,0);
set(gcf, 'Resize', on)
Matlab creates a new figure, which however still is not resizeable. How do I reactivate the option to resize the window of the figure?
Thank you!

답변 (3개)

Orion
Orion 2014년 11월 18일
편집: Orion 2014년 11월 18일
Hi,
In your callback function, don't use gcf, but the handle of your figure ( figure1 by default)
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
newfig = copyobj(handles.figure1,0); % copy the the figure to an exact new one
set(newfig, 'Resize', 'on'); % the copy is resizable

Frank
Frank 2014년 11월 20일
편집: Frank 2014년 11월 20일
Thanks, that is working perfectly. Is there an option to 'handle' ALL axes, drop-down-menus etc. in that new figure and have them change size according to window size? I would usually do this by switching their units to 'normalized', but this is not working:
newfig = copyobj(handles.figure1,0);
set(gcf, 'Resize', 'on'); %this is working now
hAxes = findobj(gcf,'type','axes');
set (hAxes, 'Units', 'normalized');
  댓글 수: 1
Orion
Orion 2014년 11월 20일
set(findall(newfig,'-property','Units'),'Units','Normalized')

댓글을 달려면 로그인하십시오.


Frank
Frank 2014년 11월 21일
편집: Frank 2014년 11월 21일
Thanks for the answer. Now everything is changing size according to window size except for the axes. They keep constant sizes even though they are the most important element to change size. This is the code I'm using:
newfig = copyobj(handles.figure1,0);
set(newfig, 'Resize', 'on');
set(findall(newfig,'-property','Units'),'Units','Normalized')
  댓글 수: 2
Orion
Orion 2014년 11월 21일
Weird. It works for me (R2014a), and I'm pretty sure, this line works for previous releases (I don't know for the 2014b)
Anymay, try this line with a simple gui with just an axe and a button. If it works, then the problem comes from your gui, in which you should have configure something, that prevent resizing.
Frank
Frank 2014년 11월 21일
Yup, that's probably it. I'll have to check the rest of my GUI. Thanks for your time so far, it's been very helpful!!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by