#NEWLINE# def createThread( parent , worker , deleteWorkerLater = False ) : #NEWLINE# #INDENT# 'Create a new thread for given worker.\n    \n    Args:\n        parent (QObject): parent of thread and worker.\n        worker (ProgressWorker): worker to use in thread.\n        deleteWorkerLater (bool, optional): delete the worker if thread finishes.\n\n    Returns:\n        QThread\n\n    ' #NEWLINE# thread = QtCore . QThread ( parent ) #NEWLINE# thread . started . connect ( worker . doWork ) #NEWLINE# worker . finished . connect ( thread . quit ) #NEWLINE# if deleteWorkerLater : #NEWLINE# #INDENT# thread . finished . connect ( worker . deleteLater ) #NEWLINE# #UNINDENT# worker . moveToThread ( parent ) #NEWLINE# worker . setParent ( parent ) #NEWLINE# return thread