def delay(self): u''' delay 延时1ms 防止gui无响应 延时1ms操作 确保窗口不会呈空白 ''' loop = QtCore.QEventLoop() QtCore.QTimer.singleShot(1, loop.quit) loop.exec_()
def run_unreal(self, **kwargs): # https://github.com/20tab/UnrealEnginePython # https://forums.unrealengine.com/development-discussion/python-scripting/1674204-dock-qtwidget-to-unreal # https://github.com/AlexQuevillon/UnrealPythonLibrary/blob/master/UnrealProject/UnrealPythonLibrary/Plugins/UnrealPythonLibraryPlugin/Content/Python/PythonLibraries/QtFunctions.py # https://forums.unrealengine.com/unreal-engine/unreal-studio/1526501-how-to-get-the-main-window-of-the-editor-to-parent-qt-or-pyside-application-to-it app = QtWidgets.QApplication.instance() if not app: # create the first instance app = QtWidgets.QApplication(sys.argv) app.aboutToQuit.connect(self.on_exit_unreal) atexit.register(self.on_exit_unreal) self.boil = None self.event_loop = QtCore.QEventLoop() self.boil = self.guiClass(None, self.window_title, self.window_object) mayapalette.set_maya_palette_with_tweaks(PALETTE_FILEPATH) unreal.parent_external_window_to_slate(self.boil.winId()) self.boil.show()
def __init__(self, __qtEventLoop=None): if __qtEventLoop is None: if self.__mainEventLoop is None or self.__mainEventLoop.__startCount == 0: raise Exception( "Main event loop is not running - perhaps you should use EventLoop.mainEventLoop()?" ) self.__qtEventLoop = QtCore.QEventLoop() else: self.__qtEventLoop = __qtEventLoop self.__runStyle = self.__RunStyle.Normal if isinstance(self.__qtEventLoop, QtWidgets.QApplication): try: import maya.OpenMaya if maya.OpenMaya.MGlobal.apiVersion() < 201100: self.__runStyle = self.__RunStyle.PumpThread else: self.__runStyle = self.__RunStyle.AlreadyRunning except ImportError: pass try: import hou if hou.applicationVersion()[0] < 14: self.__runStyle = self.__RunStyle.Houdini else: self.__runStyle = self.__RunStyle.AlreadyRunning except ImportError: pass try: import nuke self.__runStyle = self.__RunStyle.AlreadyRunning except ImportError: pass self.__startCount = 0 self.__pumpThread = None self.__houdiniCallback = None
def run_blender(self, **kwargs): """Run in Blender""" # mix of code from # https://github.com/friedererdmann/blender_pyside2_example # and # https://github.com/techartorg/bqt # TODO add dockable? # https://github.com/cube-creative/guibedos/blob/master/guibedos/blender.py app = QtWidgets.QApplication.instance() if not app: # create the first instance app = QtWidgets.QApplication(sys.argv) # modal bpy.app.timers.register(self.on_update_blender, persistent=True) atexit.register(self.on_exit_blender) self.event_loop = QtCore.QEventLoop() self.boil = self.guiClass(None, self.window_title, self.window_object) mayapalette.set_maya_palette_with_tweaks(PALETTE_FILEPATH) self.boil.show()
def _event_loop_kick(dummy): if QtCore.QEventLoop().isRunning(): QtCore.QEventLoop().processEvents()