Example #1
0
def getPrinter(window, caption=None, printer=None, allowPrintToFile=True):
    """Opens a Print Dialog and waits for user interaction.
    
    If the dialog is accepted, the configured printer (a QPrinter) is
    returned, otherwise None.
    
    window is the parent window for the print dialog.
    If printer is given, it must be a QPrinter instance.
    If allowPrintToFile=False, printing to a file is not allowed.
    
    """
    if printer is None:
        printer = QPrinter()
    dlg = KdePrint.createPrintDialog(printer, window)
    if caption:
        dlg.setWindowTitle(KDialog.makeStandardCaption(caption))
    dlg.setOption(dlg.PrintToFile, allowPrintToFile)
    if dlg.exec_():
        return printer