In property page callbacks like OnClicked and OnChanged, you can use the PPG object to access the parameters on the property page. For example:
The docs say that PPG is a global variable, but if you try to use PPG outside of a callback, you’ll get a “name is not defined” error.
Or, if you try to put all your callbacks into a separate module, you’ll get that “name is not defined” error again. Several XSI users have hit this problem:
Subject : Re: PPG in self-installable plugins
If you just start the script editor and type:
#NameError: name 'PPG' is not defined
But in the aforementioned callback if you do:
def TestProp_text_OnChanged( ):
if 'PPG' in globals():
It’ll find PPG in the globals. When did it get there and how? And more importantly who’s globals?
globals() is module specific (Dive into Python, 8.5 – locals and globals) so if I define a decorator in a separate module it can’t access the global PPG that lives in the global namespace of my plugin.
Arrggsjabcsjdbhcsd!!! My brain is turning to mush!
So what’s up with this PPG object? Where does it come from, and why can’t you access it when you put the callback function into a module?
The answer is that the callback is executed in its own instance of the scripting engine, with its own namespace.
To execute the callback, XSI creates a script engine for the logic (aka the ppg callbacks), and inserts the PPG object into the scripting engine namespace.
When I answered this question back in 2005 on the XSI list, I was officially named one of the ten coolest people in the Universe :-).