adrianpueyo / KnobScripter

Python script editor for Nuke that can script on .py files and python knobs, with all the functionality from Nuke's default script editor plus syntax helpers.
GNU General Public License v3.0
81 stars 16 forks source link

[bug] Fails to use QtGui.QStringListModel in Nuke12 #4

Closed fynnay closed 3 years ago

fynnay commented 4 years ago

On Linux in Nuke12.0v3 the panel fails to load because of a PySide2 error:

log only shows partical paths because company privacy and stuff

Traceback (most recent call last):
  File "(...)/Nuke12.0v3/plugins/nukescripts/panels.py", line 153, in makeUI
    self.widget = self.widgetClass()
  File "~/.nuke/Scripts/KnobScripter/knob_scripter.py", line 1649, in __init__
    super(KnobScripterPane, self).__init__()
  File "~/.nuke/Scripts/KnobScripter/knob_scripter.py", line 123, in __init__
    self.initUI()
  File "~/.nuke/Scripts/KnobScripter/knob_scripter.py", line 357, in initUI
    self.script_editor = KnobScripterTextEditMain(self, self.script_output)
  File "~/.nuke/Scripts/KnobScripter/knob_scripter.py", line 2756, in __init__
    self.nukeCompleter.setModel(QtGui.QStringListModel())
AttributeError: 'module' object has no attribute 'QStringListModel'

My workaround so far is just to extend the PySide2 import part at the top like this:

try:
    if nuke.NUKE_VERSION_MAJOR < 11:
        from PySide import QtCore, QtGui, QtGui as QtWidgets
        from PySide.QtCore import Qt
    else:
        from PySide2 import QtWidgets, QtGui, QtCore
        from PySide2.QtCore import Qt
        if nuke.NUKE_VERSION_MAJOR > 11:
            from PySide2.QtCore import QStringListModel
        else:
            from PySide2.QtGui import QStringListModel
except ImportError:
    from Qt import QtCore, QtGui, QtWidgets
adrianpueyo commented 3 years ago

This is resolved now! Thank you :)