Hi Victor,

If you want that sort of customization, I think you'll be better off
building your own EvalString + PythonButton combo, instead of a File_Knob.

As far as I know, File_Knob calls nuke.getFileName(), but doesn't let you
tap into the arguments of that call. Instead, you could build your own "File
Knob" using an EvalString knob and a PyScript knob (you can even give it a
folder icon to make it look more like a standard File_Knob).
It may not be as pretty as using a regular File_Knob, but the advantage is
that you can then have full control over the actions triggered when you
press the "file" button, including the use of getClipname or getFilename
with any arguments you want (filter pattern, default path, etc).

Here's an example:

##################

n = nuke.createNode('Group')

stringKnob = nuke.EvalString_Knob('image_file')

buttonKnob = nuke.PyScript_Knob('fileOpen', '<img
src=":qrc/images/File_Knob.png">')

buttonKnob.setValue("""

file = nuke.getClipname('Choose sequence...', pattern = '*.png', default =
'/default/path')

if file:

    nuke.thisNode()['image_file'].setValue(file)

""")

n.addKnob(stringKnob)

n.addKnob(buttonKnob)

###################

Hope that helps.

Cheers,
Ivan


On Wed, May 18, 2011 at 1:59 PM, Victor Perez <i...@victorperez.co.uk>wrote:

> Hi,
>
> I'm trying to customise a 'filename...' knob existing in a group node by
> adding a default text in the 'File name' field (ie. 'Select your image') and
> a default filter (ie. '*.png').
>
> This is the line of code for that knob but I don't know how to modify it to
> add that default file name and the filter:
>
> * addUserKnob {2 image_file l "image file" t "your image file"}*
>
> Thanks in advance for your help.
>
> Best,
>
> Victor
>
> _______________________________________________
> Nuke-python mailing list
> Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>
>
_______________________________________________
Nuke-python mailing list
Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to