Javier, thanks. Works great. Exactly what I need. Cheers -Ean

On Sun, Nov 20, 2011 at 7:39 PM, Javier Garcia <[email protected]> wrote:

> Hi,
>
> This code will mimic Save Preferences button behavior.
>
> Hope it helps.
>
> Javi
>
>
>
>
> import nuke
>
> prefs = nuke.toNode( 'preferences' )
>
> # My custom knob in preferences
> #prefs.addKnob( nuke.File_Knob( 'file' , 'myFile' ) )
>
> preferences_code = """
>
> Preferences {
>  inputs 0
>  name Preferences
> %s
> }
>
> """ % prefs.writeKnobs( nuke.WRITE_USER_KNOB_DEFS |
> nuke.WRITE_NON_DEFAULT_ONLY | nuke.TO_SCRIPT | nuke.TO_VALUE )
>
> import os
>
> preference_file = os.path.expandvars( '$HOME/.nuke/preferences6.3.nk' )
>
> f = open( preference_file , 'w' )
>
> f.write( preferences_code )
>
> f.close()
>
>
>
>
>
> El 20 de noviembre de 2011 19:26, Brogan Ross <[email protected]>escribió:
>
> I think you could still remove knobs from the preferences node like you
>> would with any other node.  But unless the user saves the preferences to
>> the xml file it only lasts for the session.  And it's th triggering the
>> save that I'm looking for.
>>
>> On Nov 19, 2011 4:07 AM, "Ean Carr" <[email protected]> wrote:
>> >
>> > Yes! I'm looking for this too but don't think it's possible. We need a
>> py binding to whatever function is called when the user clicks the 'Save
>> Prefs' button. Currently, this is stopping me from adding knobs to the
>> prefs node because once they're there, they're there. I couldn't find a way
>> to remove them later on should the need arise -- AFAIK -- without wiping
>> the user's prefs file and starting from scratch.
>> >
>> > I thought I mailed support about this a while ago but can't seem to
>> find a record of ever doing so.
>> >
>> > -Ean
>> >
>> > On Sat, Nov 19, 2011 at 1:37 AM, Brogan Ross <[email protected]>
>> wrote:
>> >>
>> >> Has anyone ever tried saving the Preferences via python?  I use
>> nuke.toNode("preferences") to edit them but I can't seem to find the knob
>> for Save Prefs.  Did I miss it or is there another way to access the
>> Preferences by python?
>> >>
>> >>
>> >> Thanks,
>> >>    Brogan
>> >>
>> >> _______________________________________________
>> >> Nuke-python mailing list
>> >> [email protected], http://forums.thefoundry.co.uk/
>> >> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>> >>
>> >
>> >
>> > _______________________________________________
>> > Nuke-python mailing list
>> > [email protected], http://forums.thefoundry.co.uk/
>> > http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>> >
>>
>> _______________________________________________
>> Nuke-python mailing list
>> [email protected], http://forums.thefoundry.co.uk/
>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>>
>>
>
> _______________________________________________
> Nuke-python mailing list
> [email protected], http://forums.thefoundry.co.uk/
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>
>
_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to