@@ -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
5155PrefsPanel = ""
5256SnippetEditPanel = ""
5357CodeGalleryPanel = ""
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
5860from 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):
20742076class 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 )
0 commit comments