Skip to content

Commit

Permalink
Fix up some issues compiling QT layouts.
Browse files Browse the repository at this point in the history
Older versions of uic.exe don't support Python, so use pyside2uic if it's available.
Fix creating qt_generated when it doesn't exist.
  • Loading branch information
zewt committed Feb 11, 2021
1 parent 1fcfce5 commit 139436a
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion scripts/zMayaTools/qt_helpers.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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']
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 139436a

Please sign in to comment.