Quiting the print dialog-pyqt
===

I defined  a print function using QPrinter and QDialog. However, when I launch the printer dialog and then press cancel, the entire mainwindow goes into not responding mode. I have tried to do `QtGui.QPrintDialog.close()` but does not work.

Code:

    import sys
    
    from PyQt4 import QtCore
    from PyQt4 import QtGui
    
    class QButton(QtGui.QWidget):
        def __init__(self, parent=None):
            QtGui.QWidget.__init__(self, parent)
            self.button = QtGui.QPushButton('Button', self)
            self.name='me'
            self.button.clicked.connect(self.calluser)
        def calluser(self):
            Appli=QtGui.QApplication(sys.argv)
            printer= QtGui.QPrinter()
            doc=QtGui.QTextDocument("Set local variables in this printing slot." )
            dialog = QtGui.QPrintDialog(printer)
            dialog.setModal(True)
            dialog.setWindowTitle("Print Document" )
            if dialog.exec_() == True:
                doc.print_(printer)
        
    # dialog.addEnabledOption(QAbstractPrintDialog.PrintSelection)
    
    
    def demo_QButton():
        app = QtGui.QApplication(sys.argv)
        tb = QButton()
        tb.show()
        app.exec_()
    
    if __name__=='__main__':
        demo_QButton()

