  | | | <DEFANGED_script >Python and the PPG global variable? | <DEFANGED_script >Python and the PPG global variable? 2005-04-28 - By Jerry Gamache
Back inspect.getsource( module.function ) returns the source code for a single function, but if all the functions in a module are of interest to your PPG you might want to try:
layout.Logic = inspect.getsource( myPPGModule )
To get all the code from myPPGModule.py in one single call.
-- --Original Message-- -- From: owner-xsi@(protected) [mailto:owner-xsi@(protected)]On Behalf Of Patrick Boucher Posted At: Wednesday, April 27, 2005 10:32 PM Posted To: xsi Conversation: <DEFANGED_script>Python and the PPG global variable? Subject: Re: <DEFANGED_script>Python and the PPG global variable?
Aloys Baillet wrote: > Sorry Patrick, but I don't think it's possible... > What you can also do is to put all the code of the scripted operator in > a separate file, and call XSIFactory.CreateScriptedOpFromFile. But in > this case you have to know where is installed the file (what I usually > do is to take the current PluginItem and ask its FileName property to > find out where I am in the filesystem, then point at the scripted op > file. The advantage of this method is that you can add as many helper > function in your code without having to add them in the operator code > with the inspect.getsource function... > Cheers, > > Aloys
That's what I'm doing as well....
in my custom command: myOpFile = os.path.join(myCmd.OriginPath, 'myOpFile.py') op = XSIFactory.CreateScriptedOpFromFile('MyOp', myOpFile, 'Python') layout = op.PPGLayout layout.Language = "Python" layout.Logic = inspect.getsource(foo) + inspect.getsource(bar)
I was just hoping there was a sexier/more practical way to do so.
If there's customOperator.Code and customOperator.FileName might be nice to have PPGLayout.Logic and PPGLayout.LogicFileName. One could assign the same file or different files to each to have all CustomOp code outside the scene. One could also imagine a world where if the PPGLayout.Logic is empty the system falls back to looking at customOperator.Code for the UI event handlers...
Thanks for the help!
-- Patrick Boucher TD - Coder - Resident geek Buzz Image Group Tel 514.848.0579 Fax 514.848.6371
www.buzzimage.com www.xsi-blog.com --- Unsubscribe? Mail Majordomo@(protected) with the following text in body: unsubscribe xsi
--- Unsubscribe? Mail Majordomo@(protected) with the following text in body: unsubscribe xsi
|
|
 |