  | | | <script >Python and the PPG global variable? | <script >Python and the PPG global variable? 2005-04-25 - By Jerry Gamache
Back The nifty func.toString() from jscript does not translate directly into str (func) in Python. You ended up calling OnInit as you were running the setup script and it is normal that PPG is not defined there.
You have some options:
1- Pass all the logic inlined in a string:
# Put all the PPG logic inside a triple quoted string. # Can be difficult to debug since syntax errors will # not be found until the PPG is opened. oLayout.Logic = """
def OnInit(): Application.LogMessage(str(dir(PPG)))
def Cons_OnChanged(): Application.LogMessage(str(dir(PPG))) """
2- Grab the function text from an imported module:
import inspect import myPPGHandlers
# Grab the code directly from the imported module: # Easier to debug since syntax errors will get caught # when importing the module, and easier to manage since # everything is in a module. oLayout.Logic = inspect.getsource(myPPGHandlers.OnInit) + \ inspect.getsource(myPPGHandlers.cons_OnChanged)
I currently don't think you can get the source code of a function defined in the setup code since that code is very quickly compiled into bytecode and the actual source text is discarded. This means that the code text must reside in a file somewhere and the import/inspect combo is you solution here.
--- Unsubscribe? Mail Majordomo@(protected) with the following text in body: unsubscribe xsi
|
|
 |