Package nukescripts :: Module pyQtAppUtils
[hide private]
[frames] | no frames]

Source Code for Module nukescripts.pyQtAppUtils

 1  # Copyright (c) 2009 The Foundry Visionmongers Ltd.  All Rights Reserved. 
 2   
 3  import nuke 
 4  from nukescripts import pyAppUtils 
 5   
6 -class pyQtAppHelper(pyAppUtils.pyAppHelper, nuke.FnPySingleton):
7 """ Helper class to initialise PySide2 in a separate thread """ 8
9 - def __init__(self, argv = [], start = None):
10 try: 11 if self.__pyQtApp: pass 12 except: 13 super(pyQtAppHelper, self).__init__(start) 14 self.__pyQtApp = None 15 16 if start: 17 self.start(argv)
18 19
20 - def getApplication(self, argv):
21 from PySide2 import QtCore, QtWidgets 22 23 if self.__pyQtApp is None: 24 self.__pyQtApp = QtWidgets.QApplication.instance() 25 return self.__pyQtApp
26 27
28 - def closeApplication(self):
29 self.__pyQtApp = None
30 31
32 - def start(self, argv):
33 super(pyQtAppHelper, self).initiate() 34 self.run(self.getApplication, (argv,))
35 36
37 - def stop(self):
38 self.run(self.closeApplication) 39 super(pyQtAppHelper, self).terminate()
40