Skip to content

Commit 522b3ae

Browse files
committedJul 9, 2021
Second Release
1 parent 0657f3b commit 522b3ae

5 files changed

+288
-75
lines changed
 

‎InstallationGuide.txt

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
W_HOTBOX INSTALLATION GUIDE
2+
3+
--------------------------------------------------------------------------------------------
4+
FRESH INSTALLATION
5+
--------------------------------------------------------------------------------------------
26

37
1 Copy 'W_hotbox.py' and 'W_hotboxManager.py' to a folder that's part of the nuke plugin path.
48

@@ -19,4 +23,11 @@ Step 4 is optional. The download ships with a set of buttons ready to use with t
1923
Click the button saying 'Import Archive' at the top right of the Manager, while making sure the 'Clipboard' knob next to it remains unchecked. A file browser appears. Navigate to the file called 'buttonBundle.hotbox' that came with the download and hit 'open'.
2024

2125

22-
*If you are running the Hotbox on KDE Linux, you might experience some transparency related issues. Check out the 'Transparency on KDE Linux' section in the user guide to see how you can resolve those problems*
26+
*If you are running the Hotbox on KDE Linux, you might experience some transparency related issues. Check out the 'Transparency on KDE Linux' section in the user guide to see how you can resolve those problems*
27+
28+
29+
--------------------------------------------------------------------------------------------
30+
UPGRADE
31+
--------------------------------------------------------------------------------------------
32+
33+
To upgrade the hotbox simply replace the old �W_hotbox.py� and �W_hotboxManager.py� with their updated versions.

‎W_hotbox.py

+103-46
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#----------------------------------------------------------------------------------------------------------
22
# Wouter Gilsing
33
# woutergilsing@hotmail.com
4-
# 21 August 2016
5-
# v1.0
4+
# 28 August 2016
5+
# v1.1
66
#----------------------------------------------------------------------------------------------------------
77

88
import nuke
@@ -16,6 +16,39 @@
1616
import colorsys
1717

1818
#----------------------------------------------------------------------------------------------------------
19+
#
20+
# USER SETTINGS TO MAKE THE HOTBOX FUNCTION PROPERLY IN A STUDIO ENVIRONMENT
21+
#
22+
#----------------------------------------------------------------------------------------------------------
23+
'''
24+
When enabled, users are able to change the location of the Hotbox Manager icons. In a studio environment,
25+
this can be unwanted. Change to False to hide the knob.
26+
'''
27+
28+
enableChangeableIconLocation = True
29+
30+
'''
31+
For a studio environment it can be useful to be able to setup multiple repositories to load buttons from,
32+
rather than having only one. Think of a show specific set of buttons, or facility wide, or both.
33+
Make sure to point the path to the folder containing the 'All','Multiple' and 'Single' folder, and to end the
34+
filepath with a '/'. Also, make sure to always use '/' rather than '\\'. All repositories should be named
35+
uniquely.
36+
'''
37+
38+
extraRepositories = []
39+
#extraRepositories.append(['NAME','/path/to/extra/repository/W_hotbox/'])
40+
41+
'''
42+
For example, this will add two extra repositories:
43+
44+
extraRepositories.append(['SHOW','server/shows/nuke/repository/W_hotbox/'])
45+
extraRepositories.append(['FACILITY','server/tools/nuke/repository/W_hotbox/'])
46+
'''
47+
48+
#----------------------------------------------------------------------------------------------------------
49+
50+
#----------------------------------------------------------------------------------------------------------
51+
1952

2053
class hotbox(QtGui.QWidget):
2154
'''
@@ -203,50 +236,59 @@ def __init__(self, mode, allItems = ''):
203236
if self.path[-1] != '/':
204237
self.path = self.path + '/'
205238

239+
self.allRepositories = list(set([self.path]+[i[1].replace('\\','/') for i in extraRepositories]))
240+
206241
self.rowMaxAmount = int(preferencesNode.knob('hotboxRowAmountAll').value())
207242

243+
self.folderList = []
244+
245+
208246
if mode == 'All':
209247

210-
self.folderList = [self.path + mode + '/']
248+
for repository in self.allRepositories:
249+
self.folderList.append(repository + mode + '/')
211250

212251
else:
213252
mirrored = False
214253
self.rowMaxAmount = int(preferencesNode.knob('hotboxRowAmountSelection').value())
215254

216-
217-
218255
if mode == 'Single':
219256

220257
if len(selectedNodes) == 0:
221258
nodeClass = 'No Selection'
222259

223260
else:
224261
nodeClass = selectedNodes[0].Class()
225-
226-
self.folderList = [self.path + mode + '/' + nodeClass]
227-
262+
263+
for repository in self.allRepositories:
264+
self.folderList.append(repository + mode + '/' + nodeClass)
265+
228266
#check if group, if so take the name of the group, as well as the class
229267

230268
if nodeClass == 'Group':
231269
nodeClass = selectedNodes[0].name()
232270
while nodeClass[-1] in [str(i) for i in range(10)]:
233271
nodeClass = nodeClass[:-1]
234-
self.folderList.append(self.path + mode + '/' + nodeClass)
272+
for repository in self.allRepositories:
273+
self.folderList.append(repository + mode + '/' + nodeClass)
235274

236275
else:
237276
#scan the 'multiple' folder for folders containing all the currently selected classes.
238277
nodeClasses = sorted(list(set([i.Class() for i in selectedNodes])))
239-
240-
self.folderList = []
241-
for i in sorted(os.listdir(self.path + mode)):
242-
if i[0] not in ['.','_']:
243-
folderClasses = sorted(i.split('-'))
244-
if nodeClasses == sorted(list(set(nodeClasses).intersection(folderClasses))):
245-
self.folderList.append(self.path + mode + '/' + i)
246-
278+
279+
for repository in self.allRepositories:
280+
try:
281+
for i in sorted(os.listdir(repository + mode)):
282+
if i[0] not in ['.','_']:
283+
folderClasses = sorted(i.split('-'))
284+
if nodeClasses == sorted(list(set(nodeClasses).intersection(folderClasses))):
285+
self.folderList.append(repository + mode + '/' + i)
286+
except:
287+
pass
288+
247289
allItems = []
248290

249-
for folder in self.folderList:
291+
for folder in list(set(self.folderList)):
250292
#check if path exists
251293
if os.path.exists(folder):
252294
for i in sorted(os.listdir(folder)):
@@ -419,6 +461,14 @@ def __init__(self, name, function = None):
419461
self.filePath = name
420462
self.bgColor = '#525252'
421463

464+
self.borderColor = '#000000'
465+
466+
#set the border color to grey for buttons from an additional repository
467+
for index,i in enumerate(extraRepositories):
468+
if name.startswith(i[1]):
469+
self.borderColor = '#959595'
470+
break
471+
422472
if function != None:
423473
self.function = function
424474

@@ -484,13 +534,12 @@ def setSelectionStatus(self, selected = False):
484534
background:%s;
485535
color:#eeeeee;
486536
"""%getSelectionColor())
487-
488537
else:
489538
self.setStyleSheet("""
490-
border: 1px solid black;
539+
border: 1px solid %s;
491540
background:%s;
492541
color:#eeeeee;
493-
"""%self.bgColor)
542+
"""%(self.borderColor, self.bgColor))
494543

495544
self.selected = selected
496545

@@ -527,38 +576,38 @@ def mouseReleaseEvent(self,event):
527576
#----------------------------------------------------------------------------------------------------------
528577

529578
def addToPreferences(knobObject):
530-
'''
531-
Add a knob to the preference panel.
532-
Save current preferences to the prefencesfile in the .nuke folder.
533-
'''
534-
preferencesNode = nuke.toNode('preferences')
579+
'''
580+
Add a knob to the preference panel.
581+
Save current preferences to the prefencesfile in the .nuke folder.
582+
'''
583+
preferencesNode = nuke.toNode('preferences')
535584

536-
if knobObject.name() not in preferencesNode.knobs().keys():
585+
if knobObject.name() not in preferencesNode.knobs().keys():
537586

538-
preferencesNode.addKnob(knobObject)
539-
savePreferencesToFile()
540-
return preferencesNode.knob(knobObject.name())
587+
preferencesNode.addKnob(knobObject)
588+
savePreferencesToFile()
589+
return preferencesNode.knob(knobObject.name())
541590

542591
def savePreferencesToFile():
543-
'''
544-
Save current preferences to the prefencesfile in the .nuke folder.
545-
Pythonic alternative to the 'ok' button of the preferences panel.
546-
'''
592+
'''
593+
Save current preferences to the prefencesfile in the .nuke folder.
594+
Pythonic alternative to the 'ok' button of the preferences panel.
595+
'''
547596

548-
nukeFolder = os.path.expanduser('~') + '/.nuke/'
549-
preferencesFile = nukeFolder + 'preferences%i.%i.nk' %(nuke.NUKE_VERSION_MAJOR,nuke.NUKE_VERSION_MINOR)
597+
nukeFolder = os.path.expanduser('~') + '/.nuke/'
598+
preferencesFile = nukeFolder + 'preferences%i.%i.nk' %(nuke.NUKE_VERSION_MAJOR,nuke.NUKE_VERSION_MINOR)
550599

551-
preferencesNode = nuke.toNode('preferences')
600+
preferencesNode = nuke.toNode('preferences')
552601

553-
customPrefences = preferencesNode.writeKnobs( nuke.WRITE_USER_KNOB_DEFS | nuke.WRITE_NON_DEFAULT_ONLY | nuke.TO_SCRIPT | nuke.TO_VALUE )
554-
customPrefences = customPrefences.replace('\n','\n ')
602+
customPrefences = preferencesNode.writeKnobs( nuke.WRITE_USER_KNOB_DEFS | nuke.WRITE_NON_DEFAULT_ONLY | nuke.TO_SCRIPT | nuke.TO_VALUE )
603+
customPrefences = customPrefences.replace('\n','\n ')
555604

556-
preferencesCode = 'Preferences {\n inputs 0\n name Preferences%s\n}' %customPrefences
605+
preferencesCode = 'Preferences {\n inputs 0\n name Preferences%s\n}' %customPrefences
557606

558-
# write to file
559-
openPreferencesFile = open( preferencesFile , 'w' )
560-
openPreferencesFile.write( preferencesCode )
561-
openPreferencesFile.close()
607+
# write to file
608+
openPreferencesFile = open( preferencesFile , 'w' )
609+
openPreferencesFile.write( preferencesCode )
610+
openPreferencesFile.close()
562611

563612
def deletePreferences():
564613
'''
@@ -568,7 +617,7 @@ def deletePreferences():
568617
allText = ''
569618
with open('%s/.nuke/preferences%s.nk'%(os.getenv('HOME'),nuke.NUKE_VERSION_STRING.split('v')[0]), 'r') as f:
570619
for i in f.readlines():
571-
if 'hotbox' not in i:
620+
if 'hotbox' not in i and 'iconLocation' not in i:
572621
allText = allText + i
573622

574623
with open('%s/.nuke/preferences%s.nk'%(os.getenv('HOME'),nuke.NUKE_VERSION_STRING.split('v')[0]), 'w') as f:
@@ -665,6 +714,10 @@ def addPreferences():
665714
except:
666715
pass
667716

717+
#hide the iconLocation knob if defined so at the top of the script (line 28)
718+
preferencesNode.knob('iconLocation').setVisible(True)
719+
if not enableChangeableIconLocation:
720+
preferencesNode.knob('iconLocation').setVisible(False)
668721
#----------------------------------------------------------------------------------------------------------
669722
#Color
670723
#----------------------------------------------------------------------------------------------------------
@@ -804,4 +857,8 @@ def getFileBrowser():
804857
nuke.menu('Nuke').addCommand('Edit/W_hotbox/Clear/Clear Everything', 'W_hotboxManager.clearHotboxManager()')
805858
nuke.menu('Nuke').addCommand('Edit/W_hotbox/Clear/Clear Section/Single', 'W_hotboxManager.clearHotboxManager(["Single"])')
806859
nuke.menu('Nuke').addCommand('Edit/W_hotbox/Clear/Clear Section/Multiple', 'W_hotboxManager.clearHotboxManager(["Multiple"])')
807-
nuke.menu('Nuke').addCommand('Edit/W_hotbox/Clear/Clear Section/All', 'W_hotboxManager.clearHotboxManager(["All"])')
860+
nuke.menu('Nuke').addCommand('Edit/W_hotbox/Clear/Clear Section/All', 'W_hotboxManager.clearHotboxManager(["All"])')
861+
862+
if len(extraRepositories) > 0:
863+
for i in extraRepositories:
864+
nuke.menu('Nuke').addCommand('Edit/W_hotbox/Special/Open Hotbox Manager - %s'%i[0], 'W_hotboxManager.showHotboxManager(path="%s")'%i[1])

0 commit comments

Comments
 (0)
Please sign in to comment.