.. wxPython Phoenix documentation

   This file was generated by Phoenix's sphinx generator and associated
   tools, do not edit by hand.

   Copyright: (c) 2011-2020 by Total Control Software
   License:   wxWindows License

.. include:: headings.inc



.. _wx.Printer:

==========================================================================================================================================
|phoenix_title|  **wx.Printer**
==========================================================================================================================================

This class represents the Windows or PostScript printer, and is the vehicle through which printing may be launched by an application.          

Printing can also be achieved through using of lower functions and classes, but this and associated classes provide a more convenient and general method of printing. 







         



.. seealso:: :ref:`Printing Framework Overview <printing framework overview>`, :ref:`wx.PrinterDC`, :ref:`wx.PrintDialog`, :ref:`wx.Printout`, :ref:`wx.PrintPreview`    







|

|class_hierarchy| Class Hierarchy
=================================

.. raw:: html

   <div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
   <img id="toggleBlock-trigger" src="_static/images/closed.png"/>
   Inheritance diagram for class <strong>Printer</strong>:
   </div>
   <div id="toggleBlock-summary" style="display:block;"></div>
   <div id="toggleBlock-content" style="display:none;">
   <p class="graphviz">
   <center><img src="_static/images/inheritance/wx.Printer_inheritance.png" alt="Inheritance diagram of Printer" usemap="#dummy" class="inheritance"/></center>
   <script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
   <map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.Printer.html" title="wx.Printer" alt="" coords="5,83,93,112"/> <area shape="rect" id="node2" href="wx.Object.html" title="wx.Object" alt="" coords="6,5,93,35"/> </map> 
   </p>
   </div>

|


|method_summary| Methods Summary
================================

================================================================================ ================================================================================
:meth:`~wx.Printer.__init__`                                                     Constructor.
:meth:`~wx.Printer.CreateAbortWindow`                                            Creates the default printing abort window, with a cancel button.
:meth:`~wx.Printer.GetAbort`                                                     Returns ``True`` if the user has aborted the print job.
:meth:`~wx.Printer.GetLastError`                                                 Return last error.
:meth:`~wx.Printer.GetPrintDialogData`                                           Returns the :ref:`print data <print data>`  associated with the printer object.
:meth:`~wx.Printer.Print`                                                        Starts the printing process.
:meth:`~wx.Printer.PrintDialog`                                                  Invokes the print dialog.
:meth:`~wx.Printer.ReportError`                                                  Default error-reporting function.
:meth:`~wx.Printer.Setup`                                                        Invokes the print setup dialog.
================================================================================ ================================================================================


|


|property_summary| Properties Summary
=====================================

================================================================================ ================================================================================
:attr:`~wx.Printer.Abort`                                                        See :meth:`~wx.Printer.GetAbort`
:attr:`~wx.Printer.PrintDialogData`                                              See :meth:`~wx.Printer.GetPrintDialogData`
================================================================================ ================================================================================


|


|api| Class API
===============


.. class:: wx.Printer(Object)

   **Possible constructors**::

       Printer(data=None)
       
   
   This class represents the Windows or PostScript printer, and is the
   vehicle through which printing may be launched by an application.



   .. method:: __init__(self, data=None)

      Constructor.                  

      Pass an optional pointer to a block of print dialog data, which will be copied to the printer object's local data. 

                


      :param `data`: 
      :type `data`: wx.PrintDialogData






      .. seealso:: :ref:`wx.PrintDialogData`, :ref:`wx.PrintData`    








   .. method:: CreateAbortWindow(self, parent, printout)

      Creates the default printing abort window, with a cancel button.                  


      :param `parent`: 
      :type `parent`: wx.Window
      :param `printout`: 
      :type `printout`: wx.Printout




      :rtype: :ref:`wx.PrintAbortDialog`








   .. method:: GetAbort(self)

      Returns ``True`` if the user has aborted the print job.                  

      :rtype: `bool`








   .. staticmethod:: GetLastError()

      Return last error.                  

      Valid after calling :meth:`Print` , :ref:`wx.PrintDialog`  or :meth:`wx.PrintPreview.Print` . 

      These functions set last error to  ``PRINTER_NO_ERROR``   if no error happened. 

      Returned value is one of the following: 



      =========================== ====================================== 
      ``wx.PRINTER_NO_ERROR``     No error happened.                     
      ``wx.PRINTER_CANCELLED``    The user cancelled printing.           
      ``wx.PRINTER_ERROR``        There was an error during printing.    
      =========================== ====================================== 

      |

                 

      :rtype: :ref:`wx.PrinterError`








   .. method:: GetPrintDialogData(self)

      Returns the :ref:`print data <print data>`  associated with the printer object.                  

      :rtype: :ref:`wx.PrintDialogData`








   .. method:: Print(self, parent, printout, prompt=True)

      Starts the printing process.                  

      Provide a parent window, a user-defined :ref:`wx.Printout`  object which controls the printing of a document, and whether the print dialog should be invoked first. 

      :meth:`Print`   could return ``False`` if there was a problem initializing the printer device context (current printer not set, for example) or the user cancelled printing. Call :meth:`GetLastError`   to get detailed information about the kind of the error.                  


      :param `parent`: 
      :type `parent`: wx.Window
      :param `printout`: 
      :type `printout`: wx.Printout
      :param `prompt`: 
      :type `prompt`: bool




      :rtype: `bool`








   .. method:: PrintDialog(self, parent)

      Invokes the print dialog.                  

      If successful (the user did not press Cancel and no error occurred), a suitable device context will be returned; otherwise ``None`` is returned; call :meth:`GetLastError`   to get detailed information about the kind of the error. 

                


      :param `parent`: 
      :type `parent`: wx.Window




      :rtype: :ref:`wx.DC`







      .. note:: 

         The application must delete this device context to avoid a memory leak.   








   .. method:: ReportError(self, parent, printout, message)

      Default error-reporting function.                  


      :param `parent`: 
      :type `parent`: wx.Window
      :param `printout`: 
      :type `printout`: wx.Printout
      :param `message`: 
      :type `message`: string







   .. method:: Setup(self, parent)

      Invokes the print setup dialog.                  

                


      :param `parent`: 
      :type `parent`: wx.Window




      :rtype: `bool`







      .. wxdeprecated:: 
         The setup dialog is obsolete, though retained for backward compatibility.    








   .. attribute:: Abort

      See :meth:`~wx.Printer.GetAbort`


   .. attribute:: PrintDialogData

      See :meth:`~wx.Printer.GetPrintDialogData`

