1
1
#----------------------------------------------------------------------------------------------------------
2
2
# Wouter Gilsing
3
3
4
- version = '1.8 '
5
- releaseDate = 'April 23 2018 '
4
+ version = '1.9 '
5
+ releaseDate = 'March 28 2021 '
6
6
7
7
#----------------------------------------------------------------------------------------------------------
8
8
#LICENSE
9
9
#----------------------------------------------------------------------------------------------------------
10
10
11
11
'''
12
- Copyright (c) 2016, Wouter Gilsing
12
+ Copyright (c) 2016-2021 , Wouter Gilsing
13
13
All rights reserved.
14
14
15
15
Redistribution and use in source and binary forms, with or without
@@ -139,7 +139,7 @@ def __init__(self, subMenuMode = False, path = '', name = '', position = ''):
139
139
lists = [[],[]]
140
140
for index , item in enumerate (allItems [2 :]):
141
141
142
- if int ((index % 4 )/ 2 ):
142
+ if int ((index % 4 )// 2 ):
143
143
lists [index % 2 ].append (item )
144
144
else :
145
145
lists [index % 2 ].insert (0 ,item )
@@ -192,7 +192,7 @@ def __init__(self, subMenuMode = False, path = '', name = '', position = ''):
192
192
#position
193
193
self .adjustSize ()
194
194
195
- self .spwanPosition = QtGui .QCursor ().pos () - QtCore .QPoint ((self .width ()/ 2 ),(self .height ()/ 2 ))
195
+ self .spwanPosition = QtGui .QCursor ().pos () - QtCore .QPoint ((self .width ()// 2 ),(self .height ()/ /2 ))
196
196
197
197
#set last position if a fresh instance of the hotbox is launched
198
198
if position == '' and not subMenuMode :
@@ -506,11 +506,12 @@ def validateRule(self, ruleFile):
506
506
507
507
#run rule
508
508
try :
509
- results = {}
510
- exec (ruleString , {}, results )
511
-
512
- if 'ret' in results .keys ():
513
- result = bool (results ['ret' ])
509
+ scope = {}
510
+ exec (ruleString , scope , scope )
511
+
512
+ if 'ret' in scope .keys ():
513
+ result = bool (scope ['ret' ])
514
+
514
515
except :
515
516
error = traceback .format_exc ()
516
517
@@ -584,7 +585,7 @@ def __init__(self, node = True, name = ''):
584
585
self .setFixedHeight (height )
585
586
586
587
#resize font based on length of name
587
- fontSize = max (5 ,(13 - (max (0 ,(len (name ) - 11 ))/ 2 )))
588
+ fontSize = int ( max (5 ,(13 - (max (0 ,(len (name ) - 11 ))/ 2 ) )))
588
589
font = QtGui .QFont (preferencesNode .knob ('UIFont' ).value (), fontSize )
589
590
self .setFont (font )
590
591
@@ -735,7 +736,9 @@ def invokeButton(self):
735
736
with nuke .toNode (hotboxInstance .groupRoot ):
736
737
737
738
try :
738
- exec self .function
739
+ scope = globals ().copy ()
740
+ exec (self .function , scope , scope )
741
+
739
742
except :
740
743
printError (traceback .format_exc (), self .filePath , self .text ())
741
744
@@ -837,7 +840,7 @@ def savePreferencesToFile():
837
840
'''
838
841
839
842
nukeFolder = os .path .expanduser ('~' ) + '/.nuke/'
840
- preferencesFile = nukeFolder + 'preferences%i.%i .nk' % (nuke .NUKE_VERSION_MAJOR ,nuke .NUKE_VERSION_MINOR )
843
+ preferencesFile = nukeFolder + 'preferences{}.{} .nk' . format (nuke .NUKE_VERSION_MAJOR , nuke .NUKE_VERSION_MINOR )
841
844
842
845
preferencesNode = nuke .toNode ('preferences' )
843
846
@@ -1144,7 +1147,7 @@ def updatePreferences():
1144
1147
#re-add all the knobs
1145
1148
addPreferences ()
1146
1149
1147
- #Restore
1150
+ #restore
1148
1151
for knob in currentSettings .keys ():
1149
1152
try :
1150
1153
preferencesNode .knob (knob ).setValue (currentSettings [knob ])
@@ -1154,6 +1157,17 @@ def updatePreferences():
1154
1157
#save to file
1155
1158
savePreferencesToFile ()
1156
1159
1160
+ # nuke 12.2v4 and 13 bug. The last tab wont be shown. Workaround is to add an extra tab
1161
+ customTabs = [k .name () for k in preferencesNode .knobs ().values () if isinstance (k , nuke .Tab_Knob )]
1162
+ if customTabs and customTabs [- 1 ] == 'hotboxLabel' :
1163
+
1164
+ # make new tab and hide it
1165
+ dummyTab = nuke .Tab_Knob ('hotboxDummyTab' , 'Dummy' )
1166
+ dummyTab .setFlag (0x00040000 )
1167
+
1168
+ addToPreferences (dummyTab )
1169
+
1170
+
1157
1171
#----------------------------------------------------------------------------------------------------------
1158
1172
#Color
1159
1173
#----------------------------------------------------------------------------------------------------------
@@ -1170,14 +1184,19 @@ def rgb2hex(rgbaValues):
1170
1184
'''
1171
1185
Convert a color stored as normalized rgb values to a hex.
1172
1186
'''
1187
+
1188
+ rgbaValues = [int (i * 255 ) for i in rgbaValues ]
1189
+
1173
1190
if len (rgbaValues ) < 3 :
1174
1191
return
1175
- return '#%02x%02x%02x' % (rgbaValues [0 ]* 255 ,rgbaValues [1 ]* 255 ,rgbaValues [2 ]* 255 )
1192
+
1193
+ return '#%02x%02x%02x' % (rgbaValues [0 ],rgbaValues [1 ],rgbaValues [2 ])
1176
1194
1177
1195
def hex2rgb (hexColor ):
1178
1196
'''
1179
1197
Convert a color stored as hex to rgb values.
1180
1198
'''
1199
+
1181
1200
hexColor = hexColor .lstrip ('#' )
1182
1201
return tuple (int (hexColor [i :i + 2 ], 16 ) for i in (0 , 2 ,4 ))
1183
1202
@@ -1309,7 +1328,7 @@ def printError(error, path = '', buttonName = '', rule = False):
1309
1328
hotboxError = '\n W_HOTBOX %sERROR: %s%s:\n %s' % ('RULE ' * int (bool (rule )), '/' .join (buttonName ), lineNumber , errorDescription )
1310
1329
1311
1330
#print error
1312
- print hotboxError
1331
+ print ( hotboxError )
1313
1332
nuke .tprint (hotboxError )
1314
1333
1315
1334
#----------------------------------------------------------------------------------------------------------
@@ -1360,6 +1379,7 @@ def addMenuItems():
1360
1379
'''
1361
1380
Add items to the Nuke menu
1362
1381
'''
1382
+
1363
1383
editMenu .addCommand ('W_hotbox/Open W_hotbox' , showHotbox , shortcut )
1364
1384
editMenu .addCommand ('W_hotbox/-' , '' , '' )
1365
1385
editMenu .addCommand ('W_hotbox/Open Hotbox Manager' , 'W_hotboxManager.showHotboxManager()' )
@@ -1455,9 +1475,9 @@ def resetMenuItems():
1455
1475
1456
1476
1457
1477
if len (extraRepositories ) > 0 :
1458
- menubar .addCommand ('W_hotbox/-' , '' , '' )
1478
+ editMenu .addCommand ('W_hotbox/-' , '' , '' )
1459
1479
for repo in extraRepositories :
1460
- menubar .addCommand ('W_hotbox/Special/Open Hotbox Manager - %s' % repo [0 ], 'W_hotboxManager.showHotboxManager(path="%s ")' % repo [1 ])
1480
+ editMenu .addCommand ('W_hotbox/Special/Open Hotbox Manager - {}' . format ( repo [0 ]) , 'W_hotboxManager.showHotboxManager(path="{} ")' . format ( repo [1 ]) )
1461
1481
1462
1482
#----------------------------------------------------------------------------------------------------------
1463
1483
@@ -1466,4 +1486,4 @@ def resetMenuItems():
1466
1486
1467
1487
#----------------------------------------------------------------------------------------------------------
1468
1488
1469
- nuke .tprint ('W_hotbox v%s , built %s .\n Copyright (c) 2016-%s Wouter Gilsing. All Rights Reserved.' % (version , releaseDate , releaseDate .split ()[- 1 ]))
1489
+ nuke .tprint ('W_hotbox v{} , built {} .\n Copyright (c) 2016-{} Wouter Gilsing. All Rights Reserved.' . format (version , releaseDate , releaseDate .split ()[- 1 ]))
0 commit comments