diff --git a/scripts/zMayaTools/qt_helpers.py b/scripts/zMayaTools/qt_helpers.py index a156640..31848d4 100644 --- a/scripts/zMayaTools/qt_helpers.py +++ b/scripts/zMayaTools/qt_helpers.py @@ -1,6 +1,6 @@ import fnmatch, os, maya, sys, subprocess from fnmatch import fnmatch -from zMayaTools import maya_logging, Qt +from zMayaTools import maya_logging, Qt, util import xml.etree.cElementTree as ET try: from StringIO import StringIO @@ -9,6 +9,11 @@ log = maya_logging.get_log() +try: + import pyside2uic +except ImportError: + pyside2uic = None + def mtime(path): try: return os.stat(path).st_mtime @@ -43,6 +48,12 @@ def compile_layout(filename, input_data, output_file): QT used to include a module to do this, which for some reason was removed, leaving us having to shell out for each file individually and no proper API. """ + # If pyside2uic is available, use it. Older versions of uic.exe don't support Python. + if pyside2uic is not None: + with open(output_file, 'w') as output: + pyside2uic.compileUi(StringIO(input_data), output) + return + # Run uic to compile the file. Since we modify the file before compiling it, we # pass the data through stdin. bin_path = '%s/bin/uic' % os.environ['MAYA_LOCATION'] @@ -77,6 +88,9 @@ def compile_all_layouts_in_path(path): qt_path = path + '/qt/' qt_generated_path = path + '/qt_generated/' + # Make sure the qt_generated directory exists. + util.mkdir_p(qt_generated_path) + # If qt_generated/__init__.py doesn't exist, create it so the directory is treated # as a module. This isn't checked into the source tree so that all of the files in # that directory can be safely deleted.