doLocalise() is (inexplicably) defined in Nuke's main menu.py, and since
these files are exec'ed, the function ends up in the global namespace.
Importing `__main__` is generally considered bad practice, but you can get
at it via sys.modules:
import sys
localizeFunc = sys.modules['__main__'].doLocalise
Don't try to bind this during Nuke's startup sequence though; Nuke's menu.py
probably won't have run yet, so you'll end up with an AttributeError. Scope
it inside your setup function instead.
-Nathan
-----Original Message-----
From: Howard Jones
Sent: Wednesday, February 26, 2014 11:22 AM
To: Nuke Python discussion
Subject: [Nuke-python] localise
Hi
I have a simple script that sets a range of parameters from a nuke.Panel
such as colourspace, before after etc…
One thing it does is to set up localise and run doLocalise(0) in the script.
(I have Frank's LocaliseThreaded script but using nuke here)
Anyway works well if I use nuke.load in menu .py
i.e. m.addCommand('setupReads', 'nuke.load("setupReads"), setupReads()')
However if I import this and run it as
m.addCommand('setupReads', 'setupReads. setupReads()' )
then doLocalise(0) has the error
NameError: global name 'doLocalise' is not defined
So I changed this to
nuke.doLocalise(0) and I get
AttributeError: 'module' object has no attribute 'doLocalise' (nuke is
imported)
So the question is how should I run doLocalise(0) which is a Nuke command
from an imported module? I can stick with the old way but intrigued to know
what I am missing.
Many thanks
Howard
_______________________________________________
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