示例#1
0
 def __init__(self, widget, name, _id):
     PythonPanel.__init__(self, name, _id)
     self.custom_knob = nuke.PyCustom_Knob(
         name, '',
         '__import__("nukescripts").panels.WidgetKnob('+widget+')'
     )
     self.addKnob(self.custom_knob)
示例#2
0
    def __init__(self, bundle, dialog_name, panel_id, widget_class, *args,
                 **kwargs):
        """
        Constructor.
        
        :param bundle: The app/engine/framework that the dialog belongs to
        :param dialog_name: Name to be displayed on the panel tab
        :param panel_id: Unique id for this panel
        :param widget_class: The class to be instantiated. Its constructor 
                             should not take any parameters.
        """

        # create a reference to the ToolkitWidgetWrapper class so that
        # we can refer to it safely using a single line of fully qualified
        # python to return it:
        #
        # __import__('sgtk')._panel_wrapper_class
        #
        # This necessary for the panel creation in Nuke
        setattr(sgtk, "_panel_wrapper_class", ToolkitWidgetWrapper)

        # we cannot pass parameters to the constructor of our wrapper class
        # directly, so instead pass them via a special class method
        ToolkitWidgetWrapper.set_init_parameters(widget_class, panel_id,
                                                 bundle, args, kwargs)

        # Run parent constructor
        nukescripts.panels.PythonPanel.__init__(self, dialog_name, panel_id)

        # now crate a one liner command that can safely refer to the widget class
        cmd = "__import__('nukescripts').panels.WidgetKnob(__import__('sgtk')._panel_wrapper_class)"

        # and lastly tell nuke about our panel object
        self.customKnob = nuke.PyCustom_Knob(dialog_name, "", cmd)
        self.addKnob(self.customKnob)
示例#3
0
def node_timer():
    node = nuke.selectedNode()
    if [
            knobname for knobname in node.allKnobs()
            if knobname.name() == 'mix' or knobname.name() == 'which'
    ]:
        if node.knob('User2'):
            pass
        else:
            knob_tk = nuke.Tab_Knob('User2', 'Timer')
            node.addKnob(knob_tk)
        if node.knob('MyWidget'):
            pass
        else:
            knob = nuke.PyCustom_Knob("MyWidget", "",
                                      "MyWidget(nuke.thisNode(),%s)" % (100))
            node.addKnob(knob)
        if node.knob('Notes'):
            pass
        else:
            knob_tk2 = nuke.Text_Knob('Notes', 'Info:')
            knob_tk2.setValue(
                "Adjust the knob to change the switching frequency")
            node.addKnob(knob_tk2)
    else:
        nuke.message('This node does not have a "mix" button.')
示例#4
0
 def __init__(self):
     super(Panel, self).__init__(pane_name, pane_id)
     self.customKnob = nuke.PyCustom_Knob(
         pane_name, '', '__import__("nukescripts").panels.WidgetKnob('
         '__import__("nukescripts").panels._kabaret_studio_widget'
         ')')
     self.addKnob(self.customKnob)
示例#5
0
def on_backdrop_created(node):
    """
    Adds 'Backdrop Pallete' tabs and knobs for newly created `nuke.BackdropNode`
    nodes. If a `nuke.Tab_Knob` with name "Backdrop" already exists on specified
    node, tab creation is aborted.

    Args:
        node(`nuke.BackdropNode`): node to add 'Backdrop Pallete' tab and knobs.
    """
    # bail if was already created.
    if node.knob("Backdrop"):
        on_backdrop_user_created(node)
        return

    # add a new tab
    tab = nuke.Tab_Knob('Backdrop')
    node.addKnob(tab)

    # link label knob
    label_link = nuke.Link_Knob('label_link', 'label')
    label_link.makeLink(node.name(), 'label')
    node.addKnob(label_link)

    # link font knob
    font_link = nuke.Link_Knob('note_font_link', 'font')
    font_link.makeLink(node.name(), 'note_font')
    node.addKnob(font_link)

    # link font size knob
    font_size_link = nuke.Link_Knob('note_font_size_link', '')
    font_size_link.makeLink(node.name(), 'note_font_size')
    font_size_link.clearFlag(nuke.STARTLINE)
    node.addKnob(font_size_link)

    # link position/size
    position_links = [['x', 'xpos'], ['y', 'ypos'], ['w', 'bdwidth'], ['h', 'bdheight']]
    for i in range(len(position_links)):
        name = position_links[i][0]
        target = position_links[i][1]

        link_knob = nuke.Link_Knob('%s_link' % name)
        link_knob.setLabel("%s:" % name)
        link_knob.makeLink(node.name(), target)

        if i == 0:
            link_knob.setFlag(nuke.STARTLINE)
        else:
            link_knob.clearFlag(nuke.STARTLINE)

        node.addKnob(link_knob)

        # nuke 9 bug fix
        node.knobs()[target].clearFlag(nuke.INVISIBLE)
        node.knobs()[target].setVisible(False)

    # create palette/color/icon/position widget
    theme_knob = nuke.PyCustom_Knob("Colors", "", "backdrop_palette.backdrop_widget.ColorSwatch(nuke.thisNode())")
    theme_knob.setFlag(nuke.STARTLINE)
    node.addKnob(theme_knob)
示例#6
0
文件: panels.py 项目: tws0002/Nuke-2
 def __init__(self, widget, name, widget_id):
     name_e = get_encoded(name, 'utf-8')
     super(_Panel, self).__init__(name_e, widget_id)
     self.custom_knob = nuke.PyCustom_Knob(
         name_e, "", "__import__('nukescripts').panels.WidgetKnob("
         "__import__('{0.__module__}', globals(), locals(), ['{0.__name__}'])"
         ".{0.__name__})".format(widget))
     self.addKnob(self.custom_knob)
示例#7
0
def on_backdrop_created(node):
    if node.knob("Backdrop"):
        on_backdrop_user_created(node)
        return

    # add a new tab
    tab = nuke.Tab_Knob('Backdrop')
    node.addKnob(tab)

    # link label knob
    label_link = nuke.Link_Knob('label_link', 'label')
    label_link.makeLink(node.name(), 'label')
    node.addKnob(label_link)

    # link font knob
    font_link = nuke.Link_Knob('note_font_link', 'font')
    font_link.makeLink(node.name(), 'note_font')
    node.addKnob(font_link)

    # link font size knob
    font_size_link = nuke.Link_Knob('note_font_size_link', '')
    font_size_link.makeLink(node.name(), 'note_font_size')
    font_size_link.clearFlag(nuke.STARTLINE)
    node.addKnob(font_size_link)

    # link position/size
    position_links = [['x', 'xpos'], ['y', 'ypos'], ['w', 'bdwidth'],
                      ['h', 'bdheight']]
    for i in range(len(position_links)):
        name = position_links[i][0]
        target = position_links[i][1]

        link_knob = nuke.Link_Knob('%s_link' % name)
        link_knob.setLabel("%s:" % name)
        link_knob.makeLink(node.name(), target)

        if i == 0:
            link_knob.setFlag(nuke.STARTLINE)
        else:
            link_knob.clearFlag(nuke.STARTLINE)

        node.addKnob(link_knob)

        # nuke 9 fix
        node.knobs()[target].clearFlag(nuke.INVISIBLE)
        node.knobs()[target].setVisible(False)

    # create palette/color/icon/position widget
    theme_knob = nuke.PyCustom_Knob(
        "Colors", "",
        "backdrop_palette.backdrop_widget.ColorSwatch( nuke.thisNode() )")
    theme_knob.setFlag(nuke.STARTLINE)
    node.addKnob(theme_knob)
示例#8
0
def create_jupyter_node(exec_cmd=''):
    noop = nuke.nodes.NoOp(name='Jupyter_Node')
    pybtn = nuke.PyScript_Knob('py_btn', 'Execute Code')
    pybtn.setFlag(nuke.STARTLINE)
    pytreebtn = nuke.PyScript_Knob('py_tree_btn', 'Execute Tree', exec_cmd)
    pyknob = nuke.PyCustom_Knob('py_edit', '', 'PyKnobEdit(node=nuke.thisNode())')

    for knob in pyknob, pybtn, pytreebtn:
        noop.addKnob(knob)

    userknob = noop.knob('User')
    userknob.setLabel('Python')
示例#9
0
def initializeNode():
    deselectAll()
    # Add shuffle to ensure there's only 1 input
    shuffle = nuke.createNode("Shuffle")
    shuffle["name"].setValue("Temp")
    merge = nuke.createNode("Merge2")
    merge.setInput(0, shuffle)
    merge["operation"].setValue("in")
    knob = nuke.Text_Knob("type", "type", "main")
    merge.addKnob(knob)
    merge.setSelected(True)
    shuffle.setSelected(True)
    group = nuke.collapseToGroup()
    customKnob = nuke.PyCustom_Knob(
        "ShuffleTable", "", "shuffleMgr.ShuffleMgrWindow(nuke.thisNode())")
    group.addKnob(customKnob)
示例#10
0
def create_lp_group():
    '''
        Wraps the whole thing inside a group node
    '''
    lp_group = nuke.createNode('Group', inpanel=False)
    lp_group['name'].setValue('TPD_LightPasses')

    with lp_group:

        inpt = nuke.nodes.Input()
        x, y = inpt.xpos(), inpt.ypos()

        dot1 = nuke.nodes.Dot(xpos=34+x, ypos=100+y, inputs=[inpt])

        create_lp_tree(lightPasses, dot1)

    knob = nuke.PyCustom_Knob("TPD_ColorPalette", 'ColorPalette', 'ColorPalette()')
    lp_group.addKnob(knob)
示例#11
0
 def __init__(self, widget, name, id):
     PythonPanel.__init__(self, name, id)
     self.customKnob = nuke.PyCustom_Knob(
         name, "",
         "__import__('nukescripts').panels.WidgetKnob(" + widget + ")")
     self.addKnob(self.customKnob)
        # we need to pass two arguments for our QLineEditNuke
        # the node, so that we can create a knob on that node
        # and some arbitrary, unique name, so we can find our knob later
        self.my_lineEdit = QLineEditNuke(self.node, 'my_line_edit')

        my_layout = QHBoxLayout()
        my_layout.addWidget(self.my_label)
        my_layout.addWidget(self.my_lineEdit)

        main_layout = QVBoxLayout()
        main_layout.setAlignment(Qt.AlignTop)
        self.setLayout(main_layout)
        main_layout.addLayout(my_layout)

    def makeUI(self):
        return self

    def updateValue(self):
        pass


# -----------------------------------------------------------------------------#
# run
# -----------------------------------------------------------------------------#

if __name__ == "__main__":
    node = nuke.createNode('NoOp')
    node.knob('name').setValue('PySideTestNode')
    knob = nuke.PyCustom_Knob("MyWidget", "", "MyWidget(nuke.thisNode())")
    node.addKnob(knob)
示例#13
0
def create_collector_node():
    noop = nuke.nodes.NoOp()
    pyknob = nuke.PyCustom_Knob("MyWidget", "", "widget")
    noop.addKnob(pyknob)
示例#14
0
def addPublishKnobsToGroupNode(g):
    tab = nuke.Tab_Knob('ftrackpub', 'ftrack Publish')
    g.addKnob(tab)

    headerKnob = nuke.PyCustom_Knob(
        'fheader', '', 'ftrack_connect_nuke.ui.knobs.HeaderKnob("{0}")'.format(
            str(uuid.uuid1())))
    headerKnob.setFlag(nuke.STARTLINE)
    g.addKnob(headerKnob)

    whitespaceKnob = nuke.Text_Knob('fwhite', '  ', '  ')
    g.addKnob(whitespaceKnob)

    browseKnob = nuke.PyCustom_Knob(
        "fpubto", "Publish to:", "ftrack_connect_nuke.ui.knobs.BrowseKnob()")
    browseKnob.setFlag(nuke.STARTLINE)
    g.addKnob(browseKnob)

    existingAssetsKnob = nuke.Enumeration_Knob('fassetnameexisting',
                                               'Existing assets:', ['New'])
    g.addKnob(existingAssetsKnob)

    nameKnob = nuke.String_Knob('ftrackassetname', 'Asset name:', '')
    g.addKnob(nameKnob)

    hrefKnob = nuke.String_Knob('componentId', 'componentId', '')
    hrefKnob.setVisible(False)
    g.addKnob(hrefKnob)

    typeKnob = nuke.Enumeration_Knob('ftrackassettype', 'Asset type:',
                                     ['No inputs connected'])
    typeKnob.setFlag(nuke.STARTLINE)
    g.addKnob(typeKnob)

    tableKnob = nuke.PyCustom_Knob("ftable", "Components:",
                                   "ftrack_connect_nuke.ui.knobs.TableKnob()")
    tableKnob.setFlag(nuke.STARTLINE)
    g.addKnob(tableKnob)

    copyFilesKnob = nuke.Boolean_Knob('fcopy', 'Force copy files', True)
    copyFilesKnob.setFlag(nuke.STARTLINE)
    copyFilesKnob.setTooltip(
        'This will force the selection of a managed ftrack Location and the '
        'files will be copied to a new place when published to ftrack. If not '
        'checked ftrack will pick a Location depending on the Storage scenario '
        'and any custom Location plugins.')
    g.addKnob(copyFilesKnob)

    scriptKnob = nuke.Boolean_Knob('fscript', 'Attach nukescript', 1)
    scriptKnob.setFlag(nuke.STARTLINE)
    g.addKnob(scriptKnob)

    commentKnob = nuke.Multiline_Eval_String_Knob('fcomment', 'Comment:', '')
    g.addKnob(commentKnob)

    refreshKnob = nuke.PyScript_Knob(
        'refreshknob', 'Refresh',
        'ftrack_connect_nuke.ui.legacy.ftrackPublishKnobChanged(forceRefresh=True)'
    )
    refreshKnob.setFlag(nuke.STARTLINE)
    g.addKnob(refreshKnob)

    publishKnob = nuke.PyScript_Knob(
        'pknob', 'Publish', 'ftrack_connect_nuke.ui.legacy.publishAssetKnob()')
    g.addKnob(publishKnob)
    publishKnob.setEnabled(False)