Wizard Custom Layout Example

You can use the optional <uidefinition> block to create custom layouts for your wizard interface. To demonstrate, a project wizard named CustomLayoutWizard is supplied as an example. It is defined in the extension CustomLayout.

This extension defines two custom layouts—one for each step in the CustomLayoutWizard wizard.


Note:  Because the basics of constructing a wizard extension are described elsewhere, this section focuses solely on aspects of layout customization.


XML Extension Definition File

Definitions follow for codes blocks in the XML extension definition file CustomLayout.xml.

In the <uidefinition> block, two layouts are defined:

  • TabularDataLayout:

    • This layout has five components: Title, Steps, TabularData, Help, and Submit.

    • This layout is referenced by the step TabularData Sample with TabularDataLayout@CustomLayout.

  • ChartLayout:

    • This layout has four components: Title, Steps, Chart, and Submit.

    • This layout is referenced by the step Chart Sample with ChartLayout@CustomLayout.

The file CustomLayout.xml follows.

<extension name="CustomLayout" version="0">
  <guid shortid="CustomWizardLayout">e7fa4157-90b7-4156-ac31-4000d1d687e1</guid>
  <script src="main.py" />
  <wizard name="CustomLayoutWizard" caption="CustomLayoutWizard" version="1" context="Project">
    <step layout="TabularDataLayout@CustomLayout" name="TabularData Sample" version="0" 
caption="TabularData Sample">
      <propertytable display="Worksheet" control="tabulardata" name="Table" caption="Table" 
persistent="False" parameterizable="False">
        <property control="quantity" name="Time" caption="Time" persistent="False" 
parameterizable="False" unit="Time" />
        <property control="quantity" name="Pressure" caption="Pressure" persistent="False" 
parameterizable="False" unit="Pressure" />
      </propertytable>
      <callbacks>
        <onrefresh>onrefreshTabularDataSample</onrefresh>
        <onreset>onresetTabularDataSample</onreset>
      </callbacks>
    </step>
    <step layout="ChartLayout@CustomLayout" name="Chart Sample" version="0" caption="Chart Sample">
      <callbacks>
        <onrefresh>onrefreshChartSample</onrefresh>
      </callbacks>
    </step>
  </wizard>
  <uidefinition>
    <layout name="TabularDataLayout">
      <component name="Title" leftoffset="10" topoffset="10" rightoffset="10" bottomattachment="Steps" 
bottomoffset="10" heighttype="FitToContent" height="0" widthtype="Percentage" width="100" 
componenttype="startPageHeaderComponent" />
      <component name="Steps" leftoffset="10" topattachment="Title" topoffset="0" 
rightattachment="TabularData" rightoffset="0" bottomattachment="Help" bottomoffset="10" 
heighttype="Percentage" height="67" widthtype="Percentage" width="30" componenttype="stepsListComponent" />
      <component name="TabularData" leftattachment="Steps" leftoffset="0" topattachment="Title" 
topoffset="0" rightoffset="10" bottomattachment="Help" bottomoffset="10" heighttype="Percentage" 
height="67" widthtype="Percentage" width="70" componenttype="tabularDataComponent" />
      <component name="Help" leftoffset="10" topattachment="TabularData" topoffset="0" rightoffset="10" 
bottomattachment="Submit" bottomoffset="10" heighttype="Percentage" height="33" widthtype="Percentage" 
width="100" componenttype="helpContentComponent" />
      <component name="Submit" leftoffset="10" topattachment="Help" topoffset="0" rightoffset="10" 
bottomoffset="10" heighttype="FitToContent" height="0" widthtype="Percentage" width="100" 
componenttype="buttonsComponent" />
    </layout>
    <layout name="ChartLayout">
      <component name="Title" leftoffset="10" topoffset="10" rightoffset="10" bottomattachment="Steps" 
bottomoffset="10" heighttype="FitToContent" height="0" widthtype="Percentage" width="100" 
componenttype="startPageHeaderComponent" />
      <component name="Steps" leftoffset="10" topattachment="Title" topoffset="0" 
rightattachment="Chart" rightoffset="0" bottomattachment="Submit" bottomoffset="10" 
heighttype="Percentage" height="100" widthtype="Percentage" width="30" componenttype="stepsListComponent" />
      <component name="Chart" leftattachment="Steps" leftoffset="0" topattachment="Title" topoffset="0" 
rightoffset="10" bottomattachment="Submit" bottomoffset="10" heighttype="Percentage" height="100" 
widthtype="Percentage" width="70" componenttype="chartComponent" />
      <component name="Submit" leftoffset="10" topattachment="Chart" topoffset="0" rightoffset="10" 
bottomoffset="10" heighttype="FitToContent" height="0" widthtype="Percentage" width="100" 
componenttype="buttonsComponent" />
    </layout>
  </uidefinition>
  <description>Demo layout</description>
</extension>

IronPython Script

The IronPython script main.py follows. This script defines all functions executed by the callbacks in the XML extension definition file. Note that the functions reference the defined layouts using GetComponent().

def onrefreshTabularDataSample(step):
    comp = step.UserInterface.GetComponent("TabularData")
    table = step.Properties["Table"]
    comp.SetPropertyTable(table)

def onrefreshChartSample(step):
    table = step.PreviousStep.Properties["Table"]
    tableValue = table.Value
    rowCount = table.RowCount

    x = []
    y = []
    for rowIndex in range(0, rowCount):
        x.append(tableValue["Table/Time"][rowIndex].Value.Value)
        y.append(tableValue["Table/Pressure"][rowIndex].Value.Value)

    comp = step.UserInterface.GetComponent("Chart")
    comp.Plot(x, y)

def onresetTabularDataSample(step):
    #nothing to do
    pass

Exposure of the Wizard Layouts

The following images show the exposure of the layouts defined in the extension CustomLayoutWizard. In both images, the layout is noted in red and individual components are noted in blue.

The layout TabularDataLayout is used for the step TabularData Sample.

Data must be entered into the component TabularData for the Next button in the component Submit to become enabled.

The layout ChartLayout is used for the step Chart Sample.

The component Chart contains the chart generated for the tabular data entered in the previous step.


Release 18.2 - © ANSYS, Inc. All rights reserved.