Here’s a basic Python example that shows how to:
- Create a dynamic, on-the-fly custom property
- Add a grid to the PPG
- Set the PPG Logic in Python
- Select rows in a GridWidget
import win32com.client from win32com.client import constants oProp = Application.ActiveSceneRoot.AddProperty( "CustomProperty", False, "GridWidgetDemo" ) oProp.AddParameter2("Row",constants.siInt4,1,1,20,0,100,constants.siClassifUnknown,constants.siPersistable + constants.siKeyable) oParameter = oProp.AddGridParameter( "DemoGrid" ) oGridData = oParameter.Value oGridData.ColumnCount = 3 oGridData.RowCount = 20 for i in range(0,oGridData.RowCount): for j in range(0,oGridData.ColumnCount): oGridData.SetCell( j, i, str(i) + "." + str(j) ) oPPGLayout = oProp.PPGLayout oGridPPGItem = oPPGLayout.AddItem( "DemoGrid" ) oGridPPGItem.SetAttribute( constants.siUINoLabel, True ) oGridPPGItem.SetAttribute( constants.siUIGridSelectionMode, constants.siSelectionHeader ) oGridPPGItem.SetAttribute( constants.siUIGridColumnWidths, "25:100:75:100" ) oGridPPGItem.SetAttribute( constants.siUIGridReadOnlyColumns, "1" ) oPPGLayout.AddRow() ; oPPGLayout.AddItem( "Row" ) oPPGLayout.AddButton( "SelectRow", "Select Row" ) oPPGLayout.EndRow() oPPGLayout.Language = "Python" oPPGLayout.Logic = ''' def SelectRow_OnClicked(): Application.LogMessage( "Select Row" ) oGridData = PPG.DemoGrid.Value oGridWidget = oGridData.GridWidget oGridWidget.ClearSelection() oGridWidget.AddToSelection( -1, PPG.Row.Value-1 ) ''' Application.InspectObj( oProp )