Demo entry 6335729



Submitted by anonymous on Dec 06, 2016 at 15:59
Language: Python. Code size: 1.0 kB.

# If this is version of Maya has PySide2 loaded (2017 onwards)
if 'PySide2' in sys.modules:
    # Repath PySide and shiboken so scripts can still call "import PySide"
    sys.modules['PySide'] = sys.modules['PySide2']
    sys.modules['shiboken'] = sys.modules['shiboken2'] 
    # Bring in pyside2uic and repath that...
    import pyside2uic
    sys.modules['pysideuic'] = sys.modules['pyside2uic']
    # Merge QtGui with QtWidgets so things like QPushButton still work
    sys.modules['PySide.QtGui'] = sys.modules['PySide2.QtGui']
    sys.modules['PySide.QtCore'] = sys.modules['PySide2.QtCore']
    # Change a weird flag that's changed in PySide2
    import PySide
    from PySide import QtGui, QtCore, QtWidgets
    setattr(sys.modules["PySide.QtGui"], "QApplication", sys.modules["PySide2.QtWidgets"].QApplication)    
    setattr(sys.modules["PySide.QtGui"].QApplication, "UnicodeUTF8", -1)

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).