Skip to content

Commit fcc8766

Browse files
author
Charles Taylor
committed
update for nuke16
1 parent 2efd57b commit fcc8766

14 files changed

+184
-326
lines changed

KnobScripter/blinkhighlighter.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import nuke
22

3-
try:
4-
if nuke.NUKE_VERSION_MAJOR < 11:
5-
from PySide import QtCore, QtGui, QtGui as QtWidgets
6-
from PySide.QtCore import Qt
7-
else:
8-
from PySide2 import QtWidgets, QtGui, QtCore
9-
from PySide2.QtCore import Qt
10-
except ImportError:
11-
from Qt import QtCore, QtGui, QtWidgets
3+
4+
if nuke.NUKE_VERSION_MAJOR >= 16:
5+
from PySide6 import QtCore, QtGui, QtWidgets
6+
from PySide6.QtCore import Qt
7+
elif nuke.NUKE_VERSION_MAJOR < 11:
8+
from PySide import QtCore, QtGui, QtGui as QtWidgets
9+
from PySide.QtCore import Qt
10+
else:
11+
from PySide2 import QtWidgets, QtGui, QtCore
12+
from PySide2.QtCore import Qt
13+
1214

1315
class KSBlinkHighlighter(QtGui.QSyntaxHighlighter):
1416
'''

KnobScripter/codegallery.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
import json
55
from functools import partial
66

7-
try:
8-
if nuke.NUKE_VERSION_MAJOR < 11:
9-
from PySide import QtCore, QtGui, QtGui as QtWidgets
10-
from PySide.QtCore import Qt
11-
else:
12-
from PySide2 import QtWidgets, QtGui, QtCore
13-
from PySide2.QtCore import Qt
14-
except ImportError:
15-
from Qt import QtCore, QtGui, QtWidgets
7+
if nuke.NUKE_VERSION_MAJOR >= 16:
8+
from PySide6 import QtCore, QtGui, QtWidgets
9+
from PySide6.QtCore import Qt
10+
elif nuke.NUKE_VERSION_MAJOR < 11:
11+
from PySide import QtCore, QtGui, QtGui as QtWidgets
12+
from PySide.QtCore import Qt
13+
else:
14+
from PySide2 import QtWidgets, QtGui, QtCore
15+
from PySide2.QtCore import Qt
1616

1717
from KnobScripter import utils, snippets, widgets, config, content, ksscripteditor
1818

@@ -263,7 +263,7 @@ def initUI(self):
263263
filter_layout.addStretch()
264264
self.reload_button = QtWidgets.QPushButton("Reload")
265265
self.reload_button.clicked.connect(self.reload)
266-
filter_layout.setMargin(0)
266+
filter_layout.setContentsMargins(0, 0, 0, 0)
267267
filter_layout.addWidget(self.reload_button)
268268

269269
self.filter_widget.setLayout(filter_layout)
@@ -274,7 +274,8 @@ def initUI(self):
274274
# 2.1. Inner scroll content
275275
self.scroll_content = QtWidgets.QWidget()
276276
self.scroll_layout = QtWidgets.QVBoxLayout()
277-
self.scroll_layout.setMargin(0)
277+
self.scroll_layout.setContentsMargins(0, 0, 0, 0)
278+
self.scroll_content.setLayout(self.scroll_layout)
278279
self.scroll_layout.addStretch()
279280
self.scroll_content.setLayout(self.scroll_layout)
280281
self.scroll_content.setContentsMargins(0, 0, 8, 0)

KnobScripter/dialogs.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
import nuke
88
import re
99

10-
try:
11-
if nuke.NUKE_VERSION_MAJOR < 11:
12-
from PySide import QtCore, QtGui, QtGui as QtWidgets
13-
from PySide.QtCore import Qt
14-
else:
15-
from PySide2 import QtWidgets, QtGui, QtCore
16-
from PySide2.QtCore import Qt
17-
except ImportError:
18-
from Qt import QtCore, QtGui, QtWidgets
10+
if nuke.NUKE_VERSION_MAJOR >= 16:
11+
from PySide6 import QtCore, QtGui, QtWidgets
12+
from PySide6.QtCore import Qt
13+
elif nuke.NUKE_VERSION_MAJOR < 11:
14+
from PySide import QtCore, QtGui, QtGui as QtWidgets
15+
from PySide.QtCore import Qt
16+
else:
17+
from PySide2 import QtWidgets, QtGui, QtCore
18+
from PySide2.QtCore import Qt
1919

2020
def ask(question, parent=None, default_yes = True):
2121
msgBox = QtWidgets.QMessageBox(parent=parent)

KnobScripter/findreplace.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77

88
import nuke
99

10-
try:
11-
if nuke.NUKE_VERSION_MAJOR < 11:
12-
from PySide import QtCore, QtGui, QtGui as QtWidgets
13-
from PySide.QtCore import Qt
14-
else:
15-
from PySide2 import QtWidgets, QtGui, QtCore
16-
from PySide2.QtCore import Qt
17-
except ImportError:
18-
from Qt import QtCore, QtGui, QtWidgets
10+
if nuke.NUKE_VERSION_MAJOR >= 16:
11+
from PySide6 import QtCore, QtGui, QtWidgets
12+
from PySide6.QtCore import Qt
13+
elif nuke.NUKE_VERSION_MAJOR < 11:
14+
from PySide import QtCore, QtGui, QtGui as QtWidgets
15+
from PySide.QtCore import Qt
16+
else:
17+
from PySide2 import QtWidgets, QtGui, QtCore
18+
from PySide2.QtCore import Qt
1919

2020

2121
class FindReplaceWidget(QtWidgets.QWidget):
@@ -105,10 +105,7 @@ def initUI(self):
105105
self.layout.addLayout(self.find_layout)
106106
self.layout.addLayout(self.replace_layout)
107107
self.layout.setSpacing(4)
108-
if nuke.NUKE_VERSION_MAJOR >= 11:
109-
self.layout.setMargin(2)
110-
else:
111-
self.layout.setContentsMargins(2, 2, 2, 2)
108+
self.layout.setContentsMargins(2, 2, 2, 2)
112109
self.layout.addSpacing(4)
113110
self.layout.addWidget(line)
114111
self.setLayout(self.layout)

KnobScripter/keywordhotbox.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
import nuke
88
from functools import partial
99

10-
try:
11-
if nuke.NUKE_VERSION_MAJOR < 11:
12-
from PySide import QtCore, QtGui, QtGui as QtWidgets
13-
from PySide.QtCore import Qt
14-
else:
15-
from PySide2 import QtWidgets, QtGui, QtCore
16-
from PySide2.QtCore import Qt
17-
except ImportError:
18-
from Qt import QtCore, QtGui, QtWidgets
10+
if nuke.NUKE_VERSION_MAJOR >= 16:
11+
from PySide6 import QtCore, QtGui, QtWidgets
12+
from PySide6.QtCore import Qt
13+
elif nuke.NUKE_VERSION_MAJOR < 11:
14+
from PySide import QtCore, QtGui, QtGui as QtWidgets
15+
from PySide.QtCore import Qt
16+
else:
17+
from PySide2 import QtWidgets, QtGui, QtCore
18+
from PySide2.QtCore import Qt
1919

2020

2121
class KeywordHotbox(QtWidgets.QDialog):
@@ -69,11 +69,8 @@ def initUI(self):
6969
else:
7070
category_help = ""
7171

72-
if nuke.NUKE_VERSION_MAJOR < 11:
73-
master_layout.setContentsMargins(0, 0, 0, 0)
74-
else:
75-
master_layout.setMargin(0)
76-
master_layout.setSpacing(0)
72+
master_layout.setContentsMargins(0, 0, 0, 0)
73+
master_layout.setSpacing(0)
7774

7875
self.setToolTip("<h2>{}</h2>".format(self.category) + category_help)
7976

KnobScripter/knob_scripter.py

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,23 @@ def symlink_ms(source, link_name):
3838

3939
os.symlink = symlink_ms
4040

41-
try:
42-
if nuke.NUKE_VERSION_MAJOR < 11:
43-
from PySide import QtCore, QtGui, QtGui as QtWidgets
44-
from PySide.QtCore import Qt
45-
else:
46-
from PySide2 import QtWidgets, QtGui, QtCore
47-
from PySide2.QtCore import Qt
48-
except ImportError:
49-
from Qt import QtCore, QtGui, QtWidgets
41+
if nuke.NUKE_VERSION_MAJOR >= 16:
42+
from PySide6 import QtCore, QtGui, QtWidgets
43+
from PySide6.QtCore import Qt
44+
elif nuke.NUKE_VERSION_MAJOR < 11:
45+
from PySide import QtCore, QtGui, QtGui as QtWidgets
46+
from PySide.QtCore import Qt
47+
QtGui.QAction = QtWidgets.QAction
48+
QtGui.QShortcut = QtWidgets.QShortcut
49+
else:
50+
from PySide2 import QtWidgets, QtGui, QtCore
51+
from PySide2.QtCore import Qt
52+
QtGui.QAction = QtWidgets.QAction
53+
QtGui.QShortcut = QtWidgets.QShortcut
5054

5155
PrefsPanel = ""
5256
SnippetEditPanel = ""
5357
CodeGalleryPanel = ""
54-
now = datetime.datetime.now()
55-
christmas = (now.month == 12 and now.day > 15) or (now.month == 1 and now.day < 15)
5658

5759
# ks imports
5860
from KnobScripter.info import __version__, __date__
@@ -374,7 +376,7 @@ def initUI(self):
374376
self.script_output.setReadOnly(1)
375377
self.script_output.setAcceptRichText(0)
376378
if config.prefs["se_tab_spaces"] != 0:
377-
self.script_output.setTabStopWidth(self.script_output.tabStopWidth() / 4)
379+
self.script_output.setTabStopDistance(self.script_output.tabStopDistance() / 4)
378380
self.script_output.setFocusPolicy(Qt.ClickFocus)
379381
self.script_output.setAutoFillBackground(0)
380382
self.script_output.installEventFilter(self)
@@ -387,7 +389,7 @@ def initUI(self):
387389
self.script_editor.cursorPositionChanged.connect(self.setTextSelection)
388390

389391
if config.prefs["se_tab_spaces"] != 0:
390-
self.script_editor.setTabStopWidth(
392+
self.script_editor.setTabStopDistance(
391393
config.prefs["se_tab_spaces"] * QtGui.QFontMetrics(config.script_editor_font).horizontalAdvance(' '))
392394

393395
# Add input and output to splitter
@@ -454,29 +456,29 @@ def initUI(self):
454456
# Preferences submenus
455457
def createPrefsMenu(self):
456458
# Actions
457-
self.echoAct = QtWidgets.QAction("Echo python commands", self, checkable=True,
459+
self.echoAct = QtGui.QAction("Echo python commands", self, checkable=True,
458460
statusTip="Toggle nuke's 'Echo all python commands to ScriptEditor'",
459461
triggered=self.toggleEcho)
460462
if nuke.toNode("preferences").knob("echoAllCommands").value():
461463
self.echoAct.toggle()
462-
self.runInContextAct = QtWidgets.QAction("Run in context (beta)", self, checkable=True,
464+
self.runInContextAct = QtGui.QAction("Run in context (beta)", self, checkable=True,
463465
statusTip="When inside a node, run the code replacing "
464466
"nuke.thisNode() to the node's name, etc.",
465467
triggered=self.toggleRunInContext)
466468
self.runInContextAct.setChecked(self.runInContext)
467-
self.helpAct = QtWidgets.QAction("&User Guide (pdf)", self, statusTip="Open the KnobScripter 3 User Guide in your browser.",
469+
self.helpAct = QtGui.QAction("&User Guide (pdf)", self, statusTip="Open the KnobScripter 3 User Guide in your browser.",
468470
shortcut="F1", triggered=self.showHelp)
469-
self.videotutAct = QtWidgets.QAction("Video Tutorial", self, statusTip="Link to the KnobScripter 3 tutorial in your browser.",
471+
self.videotutAct = QtGui.QAction("Video Tutorial", self, statusTip="Link to the KnobScripter 3 tutorial in your browser.",
470472
triggered=self.showVideotut)
471-
self.nukepediaAct = QtWidgets.QAction("Show in Nukepedia", self,
473+
self.nukepediaAct = QtGui.QAction("Show in Nukepedia", self,
472474
statusTip="Open the KnobScripter download page on Nukepedia.",
473475
triggered=self.showInNukepedia)
474-
self.githubAct = QtWidgets.QAction("Show in GitHub", self, statusTip="Open the KnobScripter repo on GitHub.",
476+
self.githubAct = QtGui.QAction("Show in GitHub", self, statusTip="Open the KnobScripter repo on GitHub.",
475477
triggered=self.showInGithub)
476-
self.snippetsAct = QtWidgets.QAction("Snippets", self, statusTip="Open the Snippets editor.",
478+
self.snippetsAct = QtGui.QAction("Snippets", self, statusTip="Open the Snippets editor.",
477479
triggered=lambda: self.open_multipanel(tab="snippet_editor"))
478480
self.snippetsAct.setIcon(QtGui.QIcon(os.path.join(config.ICONS_DIR, "icon_snippets.png")))
479-
self.prefsAct = QtWidgets.QAction("Preferences", self, statusTip="Open the Preferences panel.",
481+
self.prefsAct = QtGui.QAction("Preferences", self, statusTip="Open the Preferences panel.",
480482
triggered=lambda: self.open_multipanel(tab="ks_prefs"))
481483
self.prefsAct.setIcon(QtGui.QIcon(os.path.join(config.ICONS_DIR, "icon_prefs.png")))
482484

@@ -532,21 +534,21 @@ def createBlinkBackupsMenu(self):
532534

533535
# Actions
534536
# TODO On opening the blink menu, show the .blink file name (../name.blink) in grey and update the checkboxes
535-
self.blink_autoSave_act = QtWidgets.QAction("Auto-save to disk on compile", self, checkable=True,
537+
self.blink_autoSave_act = QtGui.QAction("Auto-save to disk on compile", self, checkable=True,
536538
statusTip="Auto-save code backup on disk every time you save it",
537539
triggered=self.blink_toggle_autosave_action)
538540
self.blink_autoSave_act.setChecked(config.prefs["ks_blink_autosave_on_compile"])
539-
# self.blinkBackups_createFile_act = QtWidgets.QAction("Create .blink scratch file",
540-
self.blink_load_act = QtWidgets.QAction("Load .blink", self, statusTip="Load the .blink code.",
541+
# self.blinkBackups_createFile_act = QtGui.QAction("Create .blink scratch file",
542+
self.blink_load_act = QtGui.QAction("Load .blink", self, statusTip="Load the .blink code.",
541543
triggered=self.blink_load_triggered)
542-
self.blink_save_act = QtWidgets.QAction("Save .blink", self, statusTip="Save the .blink code.",
544+
self.blink_save_act = QtGui.QAction("Save .blink", self, statusTip="Save the .blink code.",
543545
triggered=self.blink_save_triggered)
544-
self.blink_versionup_act = QtWidgets.QAction("Version Up", self, statusTip="Version up the .blink file.",
546+
self.blink_versionup_act = QtGui.QAction("Version Up", self, statusTip="Version up the .blink file.",
545547
triggered=self.blink_versionup_triggered)
546-
self.blink_browse_act = QtWidgets.QAction("Browse...", self, statusTip="Browse to the blink file's directory.",
548+
self.blink_browse_act = QtGui.QAction("Browse...", self, statusTip="Browse to the blink file's directory.",
547549
triggered=self.blink_browse_action)
548550

549-
self.blink_filename_info_act = QtWidgets.QAction("No file specified.", self,
551+
self.blink_filename_info_act = QtGui.QAction("No file specified.", self,
550552
statusTip="Displays the filename specified "
551553
"in the kernelSourceFile knob.")
552554
self.blink_filename_info_act.setEnabled(False)
@@ -2074,7 +2076,7 @@ def setRunInContext(self, pressed):
20742076
class KnobScripterPane(KnobScripterWidget):
20752077
def __init__(self):
20762078
super(KnobScripterPane, self).__init__(is_pane=True, _parent=QtWidgets.QApplication.activeWindow())
2077-
ctrl_s_shortcut = QtWidgets.QShortcut(QtGui.QKeySequence("Ctrl+S"), self)
2079+
ctrl_s_shortcut = QtGui.QShortcut(QtGui.QKeySequence("Ctrl+S"), self)
20782080
ctrl_s_shortcut.activatedAmbiguously.connect(self.saveClicked)
20792081

20802082
def showEvent(self, the_event):
@@ -2115,10 +2117,6 @@ def __init__(self, knob_scripter="", _parent=None, initial_tab="code_gallery", l
21152117
self.lang = lang
21162118

21172119
self.initUI()
2118-
# Christmas mode...
2119-
if christmas:
2120-
from KnobScripter import letItSnow # Nice one, Fynn Laue...
2121-
# self.letItSnow = letItSnow.LetItSnow(parent=self)
21222120
self.setWindowIcon(QtGui.QIcon(config.KS_ICON_PATH))
21232121
self.set_tab(initial_tab)
21242122
self.set_lang(self.lang)

KnobScripter/ksscripteditor.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
import re
1616
import logging
1717

18-
try:
19-
if nuke.NUKE_VERSION_MAJOR < 11:
20-
from PySide import QtCore, QtGui, QtGui as QtWidgets
21-
from PySide.QtCore import Qt
22-
else:
23-
from PySide2 import QtWidgets, QtGui, QtCore
24-
from PySide2.QtCore import Qt
25-
except ImportError:
26-
from Qt import QtCore, QtGui, QtWidgets
18+
if nuke.NUKE_VERSION_MAJOR >= 16:
19+
from PySide6 import QtCore, QtGui, QtWidgets
20+
from PySide6.QtCore import Qt
21+
elif nuke.NUKE_VERSION_MAJOR < 11:
22+
from PySide import QtCore, QtGui, QtGui as QtWidgets
23+
from PySide.QtCore import Qt
24+
else:
25+
from PySide2 import QtWidgets, QtGui, QtCore
26+
from PySide2.QtCore import Qt
2727

2828
from KnobScripter import config, blinkhighlighter, pythonhighlighter
2929

KnobScripter/ksscripteditormain.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
import re
1414
import sys
1515

16-
try:
17-
if nuke.NUKE_VERSION_MAJOR < 11:
18-
from PySide import QtCore, QtGui, QtGui as QtWidgets
19-
from PySide.QtCore import Qt
20-
else:
21-
from PySide2 import QtWidgets, QtGui, QtCore
22-
from PySide2.QtCore import Qt
23-
except ImportError:
24-
from Qt import QtCore, QtGui, QtWidgets
16+
if nuke.NUKE_VERSION_MAJOR >= 16:
17+
from PySide6 import QtCore, QtGui, QtWidgets
18+
from PySide6.QtCore import Qt
19+
elif nuke.NUKE_VERSION_MAJOR < 11:
20+
from PySide import QtCore, QtGui, QtGui as QtWidgets
21+
from PySide.QtCore import Qt
22+
else:
23+
from PySide2 import QtWidgets, QtGui, QtCore
24+
from PySide2.QtCore import Qt
2525

2626

2727
from KnobScripter.ksscripteditor import KSScriptEditor

0 commit comments

Comments
 (0)