Skip to content

Commit

Permalink
Fifth Release
Browse files Browse the repository at this point in the history
  • Loading branch information
melMass committed Jul 9, 2021
1 parent 287147b commit ef0882c
Show file tree
Hide file tree
Showing 4 changed files with 588 additions and 55 deletions.
2 changes: 1 addition & 1 deletion InstallationGuide.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import W_hotbox, W_hotboxManager

3.a Copy the folder named 'icons' to your .nuke folder. (If you would rather place the icons elsewhere, make sure to follow step 3.b. If you decide to put them in the default location, you can skip step 3.b)

3.b Launch Nuke. Open the Preferences Panel and navigate to the W_hotbox tab. change the path pointing to the icons folder to the folder you placed the icons in step 3.a.
3.b Launch Nuke. Open the Preferences Panel and navigate to the W_hotbox tab. Change the path pointing to the icons folder to the folder you placed the icons in step 3.a. Restart Nuke.

Step 4 is optional. The download ships with a set of buttons ready to use with the hotbox. The hotbox will function fine without those, but the user has to add buttons himself before the hotbox becomes useful. The buttons that ship with this download are easily removed if the user would rather start from scratch himself.

Expand Down
148 changes: 107 additions & 41 deletions W_hotbox.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#----------------------------------------------------------------------------------------------------------
# Wouter Gilsing
# [email protected]
version = '1.3'
releaseDate = 'Sept 4 2016'
version = '1.4'
releaseDate = 'November 16 2016'

#----------------------------------------------------------------------------------------------------------
#
Expand Down Expand Up @@ -44,6 +44,7 @@
import os
import subprocess
import platform
import traceback

import colorsys

Expand All @@ -65,16 +66,25 @@ def __init__(self, subMenuMode = False, path = '', name = '', position = ''):
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)

masterLayout = QtGui.QVBoxLayout()

self.setLayout(masterLayout)

self.selection = nuke.selectedNodes()

#check whether selection in group
self.groupRoot = 'root'

if len(self.selection) != 0:
nodeRoot = self.selection[0].fullName()
if nodeRoot.count('.') > 0:
self.groupRoot = '.'.join(nodeRoot.split('.')[:-1])

#--------------------------------------------------------------------------------------------------
#main hotbox
#--------------------------------------------------------------------------------------------------

if not subMenuMode:

self.selection = nuke.selectedNodes()

if len(self.selection) > 1:

if len(list(set([i.Class() for i in nuke.selectedNodes()]))) == 1:
Expand Down Expand Up @@ -347,7 +357,7 @@ def __init__(self, mode, allItems = ''):
class hotboxCenter(QtGui.QLabel):
'''
Center button of the hotbox.
If the 'color nodes' is set to True in the preferencespanel, the button will take over the color and
If the 'color nodes' is set to True in the preferences panel, the button will take over the color and
name of the current selection. If not, the button will be the same color as the other buttons will
be in their selected state. The text will be read from the _name.json file in the folder.
'''
Expand Down Expand Up @@ -508,20 +518,73 @@ def __init__(self, name, function = None):
self.setMouseTracking(True)
self.setFixedWidth(105)
self.setFixedHeight(35)

fontSize = preferencesNode.knob('hotboxFontSize').value()
font = QtGui.QFont(preferencesNode.knob('UIFont').value(), fontSize, QtGui.QFont.Bold)

self.setFont(font)
self.setWordWrap(True)
self.setTextFormat(QtCore.Qt.RichText)

self.setText(name)


self.setAlignment(QtCore.Qt.AlignCenter)

self.selected = False
self.setSelectionStatus()

def invokeButton(self):
'''
Execute script attached to button
'''
with nuke.toNode(hotboxInstance.groupRoot):
try:
exec self.function
except:
self.printError(traceback.format_exc())

def printError(self, error):

fullError = error.splitlines()

lineNumber = 'error determining line'

for index, line in enumerate(reversed(fullError)):
if line.startswith(' File "<'):

for i in line.split(','):
if i.startswith(' line '):
lineNumber = i

index = len(fullError)-index
break

fullError = fullError[index:]

errorDescription = '\n'.join(fullError)

scriptFolder = os.path.dirname(self.filePath)
scriptFolderName = os.path.basename(scriptFolder)

buttonName = [self.text()]

while len(scriptFolderName) == 3 and scriptFolderName.isdigit():

name = open(scriptFolder+'/_name.json').read()
buttonName.insert(0, name)
scriptFolder = os.path.dirname(scriptFolder)
scriptFolderName = os.path.basename(scriptFolder)

for i in range(2):
buttonName.insert(0, os.path.basename(scriptFolder))
scriptFolder = os.path.dirname(scriptFolder)

hotboxError = '\nW_HOTBOX ERROR: %s -%s:\n\n%s'%('/'.join(buttonName),lineNumber,errorDescription)

#print error
print hotboxError
nuke.tprint(hotboxError)

def setSelectionStatus(self, selected = False):
'''
Define the style of the button for different states
Expand Down Expand Up @@ -563,11 +626,14 @@ def mouseReleaseEvent(self,event):
if self.selected:
nuke.Undo().name(self.text())
nuke.Undo().begin()
try:
exec self.function
except:
pass



self.invokeButton()


nuke.Undo().end()

return True

#----------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -838,37 +904,6 @@ def getSelectionColor():

#----------------------------------------------------------------------------------------------------------

def showHotbox(force = False, resetPosition = True):

global hotboxInstance
if force:
hotboxInstance.active = False
hotboxInstance.close()

if resetPosition:
global lastPosition
lastPosition = ''

if hotboxInstance == None or not hotboxInstance.active:
hotboxInstance = hotbox(position = lastPosition)
hotboxInstance.show()

def showHotboxSubMenu(path, name):
global hotboxInstance
hotboxInstance.active = False
if hotboxInstance == None or not hotboxInstance.active:
hotboxInstance = hotbox(True, path, name)
hotboxInstance.show()

def showHotboxManager():
'''
Open the hotbox manager from the hotbox
'''
hotboxInstance.closeHotbox()
W_hotboxManager.showHotboxManager()

#----------------------------------------------------------------------------------------------------------

def revealInBrowser(startFolder = False):
'''
Reveal the hotbox folder in a filebrowser
Expand Down Expand Up @@ -909,6 +944,37 @@ def getFileBrowser():

return fileBrowser

#----------------------------------------------------------------------------------------------------------

def showHotbox(force = False, resetPosition = True):

global hotboxInstance

if force:
hotboxInstance.active = False
hotboxInstance.close()

if resetPosition:
global lastPosition
lastPosition = ''

if hotboxInstance == None or not hotboxInstance.active:
hotboxInstance = hotbox(position = lastPosition)
hotboxInstance.show()

def showHotboxSubMenu(path, name):
global hotboxInstance
hotboxInstance.active = False
if hotboxInstance == None or not hotboxInstance.active:
hotboxInstance = hotbox(True, path, name)
hotboxInstance.show()

def showHotboxManager():
'''
Open the hotbox manager from the hotbox
'''
hotboxInstance.closeHotbox()
W_hotboxManager.showHotboxManager()

#----------------------------------------------------------------------------------------------------------

Expand Down
Loading

0 comments on commit ef0882c

Please sign in to comment.