If you have a gizmo, I would go one step further and use the callback 
registration mechanism instead of the 'knobChanged' knob. Also, if you’re 
reading a file when the panel is shown, I would cache your results and some 
indicator that the file has been read already. You can provide a 'refresh' 
button if need be to manually re-read the file and re-cache the data.

-Nathan



From: Hugo Léveillé 
Sent: Thursday, May 16, 2013 6:14 AM
To: Nuke Python discussion 
Subject: Re: [Nuke-python] Two questions about callbacks and writing python

I find it easier to edit the code in a dedicated editor. And the gizmo will 
update live when you save your code while developing. Much faster then 
copy/pasting the code everytime in the Nuke script editor to set the value 
again and again...

On Thu, May 16, 2013, at 3:18, Howard Jones wrote:
  Is that the best way then? I always write into the knobChanged direct in the 
node. Though via
  s=''' script stuff '''
  ...['knobChanged'].setValue(s) 

  What's the advantage of keeping it external?

  Howard

  On 16 May 2013, at 02:03, Frank Rueter <fr...@beingfrank.info> wrote:
   
    You probably want to run the code every time the gizmo's panel is opened, 
so look into the knobChanged knob.
    I'd write the python code in an external file and import then execute it 
inside the knobChanged knob.

    This might get you started:
    http://pastebin.com/Ca9eMNUQ



    On 11/05/13 06:36, thinkinmonkey wrote:
      Hello everyone,
      I wrote a very simple gizmo in Nuke and I'd love to refine it with your 
help.
      The gizmo simply reads an xml file where I stored some data, the user can 
select a scene/shot from a pulldown choice and he will have the images sequence 
of that scene/shot.
      Everything works, but I'd want to know:

      a) When the user create the gizmo from menu, he's forced to click a 
button on gizmo in order to load the xml file, otherwise the gizmo is not able 
to load the image sequence. I want the gizmo load the xml file automatically, I 
tried the callbacks, the "on Create" function, but with no success. Could you 
tell me how to do that?

      b) Just to be sure, I put all python code in a python script button knob: 
is that right to program? I mean, if I want to write python functions or 
callbacks that control the entire gizmo, the only solution I have is to write 
then in a button, but they are executed only when user clicks on it, isn't? 
There's another way to create a new node/plugin?

      Thanks in advance.

       

_______________________________________________
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
  _______________________________________________
  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

-- 
Hugo Léveillé
TD Compositing, Vision Globale
hu...@fastmail.net


--------------------------------------------------------------------------------
_______________________________________________
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