Autodesk Softimage Services & Support

Setting PPGLayout.Logic in Python

Issue

You are dynamically creating a property page in Python and you want to provide some callback code to handle PPG events. In JScript, you would use the toString() method to set the PPGLayout.Logic property, but there is no such method in Python.

Solution

In Python, put your function definitions in triple quotes and then assign the string to PPGLayout.Logic:

import win32com

xsi = Application
c = win32com.client.constants




# Create a temporary custom property


oProp = XSIFactory.Createobject( 'CustomProperty' )

oPar = oProp.addparameter3( 'Test', c.siString, 'Test' ) oLayout = oProp.PPGLayout oLayout.Clear() oLayout.Language = "Python" oLayout.addbutton( oPar.scriptname, oPar.scriptname ) # Note that you have to define variables like 'xsi'
# The PPG Logic code cannot access any variables
# defined outside of the Logic code sLogic = ''' xsi = Application def Test_OnClicked(): xsi.LogMessage( 'Hello World' )''' oLayout.Logic = sLogic # This works too: #f = open("C:/My Documents/callbacks.txt") #s = f.read() #oLayout.Logic = s xsi.inspectobj( oProp )

Support – Terms of Use
  • Did this page resolve your issue?
  • Translate This Page (Beta)

    Learn More about this translation beta.Page is machine translated. Learn More.

    Was this translation useful?

  • Document Information

    Published date: 2009-Nov-03
    ID: TS14003709

     

    Applies to:
    Autodesk® Softimage® 2014
    Autodesk® Softimage® 2013
    Autodesk® Softimage® 2012
    Autodesk® Softimage® 2011
    Autodesk® Softimage® 2010
    Autodesk® Softimage® 7.5
    Autodesk Softimage Advanced 2010
    Autodesk Softimage Advanced 7.5