Skip to content

Commit 225803b

Browse files
committed
Tenth Release
1 parent cda43f7 commit 225803b

34 files changed

+158
-92
lines changed

InstallationGuide.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ W_HOTBOX INSTALLATION GUIDE
44
FRESH INSTALLATION
55
--------------------------------------------------------------------------------------------
66

7-
1 Copy 'W_hotbox.py' and 'W_hotboxManager.py' to a folder that's part of the nuke plugin path.
7+
1 Copy 'W_hotbox.py' and 'W_hotboxManager.py' to a folder that's part of the nuke plugin path. (Usually inside ~/user/.nuke)
88

99
2 Append menu.py with the following code:
1010

W_hotbox.py

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
#----------------------------------------------------------------------------------------------------------
22
# Wouter Gilsing
33
4-
version = '1.8'
5-
releaseDate = 'April 23 2018'
4+
version = '1.9'
5+
releaseDate = 'March 28 2021'
66

77
#----------------------------------------------------------------------------------------------------------
88
#LICENSE
99
#----------------------------------------------------------------------------------------------------------
1010

1111
'''
12-
Copyright (c) 2016, Wouter Gilsing
12+
Copyright (c) 2016-2021, Wouter Gilsing
1313
All rights reserved.
1414
1515
Redistribution and use in source and binary forms, with or without
@@ -139,7 +139,7 @@ def __init__(self, subMenuMode = False, path = '', name = '', position = ''):
139139
lists = [[],[]]
140140
for index, item in enumerate(allItems[2:]):
141141

142-
if int((index%4)/2):
142+
if int((index%4)//2):
143143
lists[index%2].append(item)
144144
else:
145145
lists[index%2].insert(0,item)
@@ -192,7 +192,7 @@ def __init__(self, subMenuMode = False, path = '', name = '', position = ''):
192192
#position
193193
self.adjustSize()
194194

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))
196196

197197
#set last position if a fresh instance of the hotbox is launched
198198
if position == '' and not subMenuMode:
@@ -506,11 +506,12 @@ def validateRule(self, ruleFile):
506506

507507
#run rule
508508
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+
514515
except:
515516
error = traceback.format_exc()
516517

@@ -584,7 +585,7 @@ def __init__(self, node = True, name = ''):
584585
self.setFixedHeight(height)
585586

586587
#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))))
588589
font = QtGui.QFont(preferencesNode.knob('UIFont').value(), fontSize)
589590
self.setFont(font)
590591

@@ -735,7 +736,9 @@ def invokeButton(self):
735736
with nuke.toNode(hotboxInstance.groupRoot):
736737

737738
try:
738-
exec self.function
739+
scope = globals().copy()
740+
exec(self.function, scope, scope)
741+
739742
except:
740743
printError(traceback.format_exc(), self.filePath, self.text())
741744

@@ -837,7 +840,7 @@ def savePreferencesToFile():
837840
'''
838841

839842
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)
841844

842845
preferencesNode = nuke.toNode('preferences')
843846

@@ -1144,7 +1147,7 @@ def updatePreferences():
11441147
#re-add all the knobs
11451148
addPreferences()
11461149

1147-
#Restore
1150+
#restore
11481151
for knob in currentSettings.keys():
11491152
try:
11501153
preferencesNode.knob(knob).setValue(currentSettings[knob])
@@ -1154,6 +1157,17 @@ def updatePreferences():
11541157
#save to file
11551158
savePreferencesToFile()
11561159

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+
11571171
#----------------------------------------------------------------------------------------------------------
11581172
#Color
11591173
#----------------------------------------------------------------------------------------------------------
@@ -1170,14 +1184,19 @@ def rgb2hex(rgbaValues):
11701184
'''
11711185
Convert a color stored as normalized rgb values to a hex.
11721186
'''
1187+
1188+
rgbaValues = [int(i * 255) for i in rgbaValues]
1189+
11731190
if len(rgbaValues) < 3:
11741191
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])
11761194

11771195
def hex2rgb(hexColor):
11781196
'''
11791197
Convert a color stored as hex to rgb values.
11801198
'''
1199+
11811200
hexColor = hexColor.lstrip('#')
11821201
return tuple(int(hexColor[i:i+2], 16) for i in (0, 2 ,4))
11831202

@@ -1309,7 +1328,7 @@ def printError(error, path = '', buttonName = '', rule = False):
13091328
hotboxError = '\nW_HOTBOX %sERROR: %s%s:\n%s'%('RULE '*int(bool(rule)), '/'.join(buttonName), lineNumber, errorDescription)
13101329

13111330
#print error
1312-
print hotboxError
1331+
print(hotboxError)
13131332
nuke.tprint(hotboxError)
13141333

13151334
#----------------------------------------------------------------------------------------------------------
@@ -1360,6 +1379,7 @@ def addMenuItems():
13601379
'''
13611380
Add items to the Nuke menu
13621381
'''
1382+
13631383
editMenu.addCommand('W_hotbox/Open W_hotbox', showHotbox, shortcut)
13641384
editMenu.addCommand('W_hotbox/-', '', '')
13651385
editMenu.addCommand('W_hotbox/Open Hotbox Manager', 'W_hotboxManager.showHotboxManager()')
@@ -1455,9 +1475,9 @@ def resetMenuItems():
14551475

14561476

14571477
if len(extraRepositories) > 0:
1458-
menubar.addCommand('W_hotbox/-', '', '')
1478+
editMenu.addCommand('W_hotbox/-', '', '')
14591479
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]))
14611481

14621482
#----------------------------------------------------------------------------------------------------------
14631483

@@ -1466,4 +1486,4 @@ def resetMenuItems():
14661486

14671487
#----------------------------------------------------------------------------------------------------------
14681488

1469-
nuke.tprint('W_hotbox v%s, built %s.\nCopyright (c) 2016-%s Wouter Gilsing. All Rights Reserved.'%(version, releaseDate, releaseDate.split()[-1]))
1489+
nuke.tprint('W_hotbox v{}, built {}.\nCopyright (c) 2016-{} Wouter Gilsing. All Rights Reserved.'.format(version, releaseDate, releaseDate.split()[-1]))

0 commit comments

Comments
 (0)