필터 지우기
필터 지우기

How to "print" on the command line or from a gui like is done from the figure "file" menu option

조회 수: 4 (최근 30일)
Hello,
To simplify life, I would like to have a button in my gui call up the same MATLAB gui window to choose the printer that is done when you choose "File Print" in Windows. I don't want a new figure window (if possible) to pop up, but just to print the chosen axes (chosen through copyobj()).
The print procedure is NOT very intuitive.
Thanks.
Doug
  댓글 수: 12
Joseph Cheng
Joseph Cheng 2014년 4월 2일
Quick search of the Matlab Answers for that gave a possible solution.
set(gcf,'Renderer','OpenGL')
Douglas Anderson
Douglas Anderson 2014년 4월 2일
Amazing! Yes, setting, the new figure to the 'Renderer','OpenGL' worked.
Thank you!
Doug
For reference, the code that WORKS is:
% --- Executes on button press in print_button.
function print_button_Callback(hObject, eventdata, handles)
% hObject handle to print_button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axis_handle = handles.printer_compo;
new_fig = figure('Visible','off');
new_axes = copyobj(axis_handle,new_fig);
set(new_axes, 'units', 'normalized', 'position', [0.13 0.11 0.775 0.815]);
set(new_fig,'Renderer','OpenGL');
pp_handle = printpreview(new_fig);
uiwait(pp_handle);
close(new_fig);

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

채택된 답변

Joseph Cheng
Joseph Cheng 2014년 4월 1일
Thinking about it more... here is what i came up with.
in GUIDE use the menu editor add in file and print as a new menu and menu item.
after that in the call back for print
TESTS=figure;
copyobj(handles.axes2,TESTS);
printpreview(TESTS);
close(TESTS);
printpreview() may not be what you are looking for but as a temporary thing to see if you are actually getting the axes you are looking for. after you know this is what you're looking for then you can swap out printpreview() with printdlg().

추가 답변 (0개)

카테고리

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