Using the properties

The data object itself has several properties, one of which is a reference to an object of type wx.PrintData, which has even more properties. You can create your wx.PrintDialogData object using the constructor, wx.PrintDialogData(). This allows you to preset properties before you open the dialog.

The wx.PrintDialogData object has four properties that control whether various parts of the print dialog are enabled. The method EnableHelp(enable) turns the help feature of the dialog on or off. Other parts of the dialog are controlled by EnablePageNumbers(enable), which covers the page number entry box, EnablePrintToFile(enable), which manages the actual print button, and EnableSelection(enable), which handles the toggle between print all and print selection only.

Print Setup


Printer Name:


^vl 1

Properties... ]




Fine Print 5









® Portrait


1 Normal

O Landscape

1 1

f Network...



f Cancel

1 1

Table 17.2 displays other properties of the dialog data object that allow you to manage information about the print request.

Table 17.2 Properties of wx.PrintDialogData




Returns True if the user has selected the option to print the entire document.

GetCollate() SetCollate(flag)

Returns True if the user has selected the option to collate the printed pages.

GetFromPage() SetFromPage(page)

Returns the integer page number of the first page to print, if the user chooses to print a page range.

GetMaxPage() SetMaxPage(page)

Returns the maximum page number in the document.

GetMinPage() SetMinPage(page)

Returns the minimum page number in the document.

GetNoCopies() SetNoCopies()

Returns the number of copies that the user has chosen to print.

GetPrintData() SetPrintData(printData)

Returns the wx.PrintData object associated with this dialog.

GetPrintToFile() SetPrintToFile(flag)

Returns True if the user has chosen the option of printing to a file. The mechanism for printing to the file is managed by wxPython.

GetSelection() SetSelection(flag)

Returns True if the user has chosen the option of printing only the current selection. The exact definition of what is considered to be the current selection is up to your application.

GetToPage() SetToPage(page)

Returns the integer page number of the last page to print if the user specifies a range.

The wx.PrintData instance returned by the GetPrintData() method provides further information about the printing. In general, these items are in the printer settings subdialog of your print dialog. Table 17.3 lists the properties in the wx.PrintData object. The wx.PrintData object duplicates the collate and number of copies properties of wx.PrintDialogData.

The second useful print dialog contains the page setup data. In the next section we'll discuss the page setup data and its use.

Table 17.3 Properties of wx.PrintData



GetColour() SetColour(flag)

Returns true if the current print is for color printing.

GetDuplex() SetDuplex(mode)

Returns the current setting for printing on both sides of the page. The possible values are wx.duplex_simple (no double-sided printing), wx.duplex_horizontal (double-sided printing as though the pages were to be bound pad-style along the horizontal edge), and wx.DUPLEX_VERTICAL (double-sided printing as though the pages were to be bound book-style along the vertical edge).

GetOrientation() SetOrientation(orientation)

Returns the orientation of the page. Possible values are wx.LANDSCAPE and wx.PORTRAIT.

GetPaperId() SetPaperld(paperld)

Returns one of several identifiers matching the paper type. Space prevents a full listing. Common values are wx.paper_letter, wx.paper_legal, and wx.PAPER_A4. See the wxWidgets documentation for a full listing of paper IDs.

GetPrinterName() SetPrinterName(printerName)

Returns the name used by the system to refer to the current printer. If the value is the empty string, the default printer is used.

GetQuality() SetQuality(quality)

Returns the current quality value of the printer. The setter only accepts the values wx.print_quality_draft, wx.PRINT_QUALITY_HIGH, wx.PRINT_QUALITY_MEDIUM, or wx.print_quality_low. The getter can return any of these, or an arbitrary positive integer representing the dots per inch setting.

Was this article helpful?

0 -1

Post a comment