To create a wizard, you add a <wizard> block in the XML
extension definition file. The existing requirements of a standard XML extension
definition file apply. No limit exists on the number of wizards that can be
added.
Within a <wizard> block, child
<step> blocks define wizard steps. Each
<step> block then has child blocks that define callbacks
and properties for the step. All blocks have a set of required and optional attributes.
For example, the <wizard> block requires the following
attributes: name, version, and
context.
You can use an optional
<uidefinition> block to customize the appearance of a
wizard that is not for AIM. In a <uidefinition> block, you
can specify layouts both for the interface as a whole and for individual interface
components. For more information on customizing the interface of a non-AIM wizard, see
Customizing the Layout of a Wizard and Wizard Custom Layout Example.
To better understand how wizards are defined, look at the following excerpt from
the XML definition file for a project wizard that is executed from the Workbench
Project tab. In this XML file for the extension
WizardDemos, the wizard Project
Wizard is defined.
Note: The XML definition syntax is the same for all project wizards, regardless of whether they are run from the Workbench or AIM Project tab.
<extension version="2" minorversion="1" name="WizardDemos"> <guid shortid="WizardDemos">7fdb141e-3383-433a-a5af-32cb19971771</guid> <author>ANSYS Inc.</author> <description>Simple extension to test wizards in different contexts.</description> <script src="main.py" /> <script src="ds.py" /> <script src="dm.py" /> <script src="sc.py" /> <interface context="Project|Mechanical|SpaceClaim"> <images>images</images> </interface> <interface context="DesignModeler"> <images>images</images> <toolbar name="Deck" caption="Deck"> <entry name="Deck" icon="deck"> <callbacks> <onclick>CreateDeck</onclick> </callbacks> </entry> <entry name="Support" icon="Support"> <callbacks> <onclick>CreateSupport</onclick> </callbacks> </entry> </toolbar> </interface> ... <wizard name="ProjectWizard" version="1" context="Project" icon="wizard_icon"> <description>Simple wizard for demonstration in Project page.</description> <step name="Geometry" caption="Geometry" version="1" HelpFile="help/geometry.html" layout="DefaultTabularDataLayout"> <description>Create a geometry component.</description> <componentStyle component="Submit"> <background-color>#b6d7a8</background-color> </componentStyle> <componentData component="TabularData"> <CanAddDelete>false</CanAddDelete> </componentData> <callbacks> <onupdate>EmptyAction</onupdate> <onreset>DeleteGeometry</onreset> <oninit>InitTabularData</oninit> </callbacks> <propertygroup display="caption" name="definition" caption="Basic properties" > <property name="filename" caption="Geometry file name" control="fileopen" /> <property name="myint" caption="Integer value" control="integer" /> <property name="mytext" caption="Text value" control="text" /> <property name="myquantity" caption="Quantity value" control="float" unit="Pressure" /> <property name="myreadonly" caption="Readonly value" control="text" readonly="true" default="My value" /> <propertygroup display="property" name="myselect" caption="List of choice" control="select" default="Option1"> <attributes options="Option1,Option2" /> <property name="option1" caption="Option1 value" control="text" visibleon="Option1" /> <property name="option2first" caption="Option2 first value" control="float" unit="Pressure" visibleon="Option2" /> <property name="option2seond" caption="Option2 second value" control="float" unit="Length" visibleon="Option2" /> </propertygroup> </propertygroup> <propertytable name="Table" caption="Table" control="custom" display="worksheet" class="Worksheet.TabularDataEditor.TabularDataEditor"> <property name="Frequency" caption="Frequency" unit="Frequency" control="float" isparameter="true"></property> <property name="Damping" caption="Damping" control="float" isparameter="true"></property> <property name="TestFileopen" caption="fileopen" control="fileopen"></property> </propertytable> <propertytable name="TableB" caption="Table B" control="tabulardata" display="worksheet"> <property name="Integer" caption="Integer" control="integer"></property> <property name="FileOpen" caption="Fileopen" control="fileopen"></property> <property name="Number" caption="Number A" unit="Pressure" control="float"></property> <property name="ReadOnly" caption="ReadOnly" unit="Pressure" control="float" readonly="true" default="4 [Pa]"/> <propertygroup display="property" name="myselect" caption="List of choice" control="select" default="Option1"> <attributes options="Option1,Option2" /> <property name="TestStr" caption="Text" control="text" visibleon="Option1"></property> <property name="Number B" caption="Number B" unit="Temperature" control="float"></property> </propertygroup> </propertytable> </step> <step name="Mechanical" caption="Mechanical" enabled="true" version="1" HelpFile="help/mechanical.html"> <description>Create a mechanical component.</description> <callbacks> <onupdate>EmptyAction</onupdate> <onreset>DeleteMechanical</onreset> </callbacks> <property name="name" caption="System name" control="text" /> </step> <step name="Fluent" caption="Fluent" version="1" HelpFile="help/fluent.html"> <description>Create a fluent component.</description> <callbacks> <onrefresh>CreateDialog</onrefresh> <onupdate>EmptyAction</onupdate> <onreset>EmptyReset</onreset> </callbacks> <property name="name" caption="System name" control="text" /> <property name="dialog" caption="Dialog" control="text"> <callbacks> <onvalidate>ValidateDialog</onvalidate> </callbacks> </property> <property name="dialog2" caption="DialogProgress" control="text"> <callbacks> <onvalidate>ValidateDialogProgress</onvalidate> </callbacks> </property> <property name="nextstep" caption="Next Step" control="select" > <callbacks> <onvalidate>ValidateNextStep</onvalidate> </callbacks> </property> </step> <step name="ReportView" caption="ReportView" version="1" layout="ReportView@WizardDemos"> <description>Simple example to demonstrate how report can be displayed.</description> <callbacks> <onrefresh>RefreshReport</onrefresh> <onreset>EmptyReset</onreset> </callbacks> </step> <step name="CustomStep" caption="CustomStep" enabled="true" version="1" layout="MyLayout@WizardDemos"> <description>Create a mechanical component.</description> <callbacks> <onrefresh>RefreshMechanical</onrefresh> <onupdate>LogReport</onupdate> <onreset>EmptyReset</onreset> </callbacks> <property name="name" caption="System name" control="text" /> </step> <step name="Charts" caption="Charts" enabled="true" version="1" layout="GraphLayout@WizardDemos"> <description>Demonstrate all chart capabilities.</description> <callbacks> <onrefresh>RefreshCharts</onrefresh> </callbacks> </step> </wizard> ... </extension>
The top-most <extension> block specifies the
extension name and version.
The <guid> block specifies a unique
identifier for the extension.
The <script> blocks define the IronPython scripts that are referenced by the wizards in the extension.
The <interface> block defines the user
interface for one or more wizards in the extension. For this example, the
attribute context for the
<interface> block is set to
Project|Mechanical|SpaceClaim.
The <wizard> block specifies the required
attributes name, version, and
context. In this example, the attribute
context is set to Project
because this wizard is executed from the Workbench
Project tab.
Optional attributes icon and
description are also defined. Icon files are
stored in the folder images in the extension
directory. You specify the location of the folder
images in the
<interface> block.
Child <step> blocks define the wizard
steps.
For a mixed wizard, the attribute context
for the wizard is still set to Project
because the wizard is launched from the Workbench
Project tab. Each step in a mixed wizard
has its context set to the ANSYS product
from which the step is executed.
For a wizard targeted for AIM, the attribute
context is not used for step definitions.
For more information, see Using an AIM Target Product Wizard.
A <step> block exists for each step in the
wizard. In a <step> block, the required
attributes name and version
are defined. The optional attribute caption sets the
display text for the step. You must set the attribute
context for a step only if it differs from the
attribute context for the wizard. All steps in this
particular wizard are executed from the Workbench
Project tab.
Note: For each step in a mixed wizard, the context is
set to the ANSYS product from which the step is executed.
Additional optional attributes can be defined for steps. For example, the
attribute HelpFile indicates the file containing
custom help content to display in the user interface. In the IronPython
script, you can also programmatically change the attribute
enabled for a step to make its display
conditional. For more information, see Creating Conditional Steps.
Child blocks define callbacks and properties.
A <callbacks> block executes a function that
has been defined in the IronPython script for the wizard. Each callback
receives the current step as a method argument.
The required callback <onupdate> is
invoked when you click the button for a
Workbench wizard step. In the wizard example, the callback
<onupdate> for the first three
steps executes the function
EmptyAction.
The callback <onrefresh> is invoked
when the next step is initialized. It initiates changes to the
interface, so you can use this callback to change the appearance of
the wizard, initialize a value to be used in the current step,
instantiate variables, access data of an existing project, and so
on. In the wizard example, the callback
<onrefresh> for the step
Fluent executes the function
CreateDialog.
The callback <onreset> resets the
state of the step so that the user can remedy a situation where the
step was not completed correctly. In the first two steps of the
example, it executes the functions
DeleteGeometry and
DeleteMechanical.
Note: For wizards targeted at AIM, only the callbacks
<onupdate>,
<onrefresh>, and
<onreset> are supported. For more
information, see Using an AIM Target Product Wizard.
A <propertygroup> block specifies groupings
of properties within the step, and a <property>
block specifies properties and property attributes. For a
<property> block, the attributes
control and name are
required. The attribute control specifies the control
type for the property. The standard property types of
select, float,
integer, scoping,
text, and fileopen are
supported. Advanced types such as applycancel and
custom are also supported.
Optional attributes can also be defined for various properties.
The attribute caption specifies the
display text for the property.
The attribute unit specifies the units
for the property value.
The attribute readonly specifies whether
the property value can be edited.
The attribute default specifies the
default property value.
The attribute visibleon specifies whether
the property is to display. In this example, the property
visibleon is used to control the display
of conditional options in a property group.
The <propertygroup> block is used to create
groupings of properties.
For the first property group in the example, no control is
defined, so that the group is a list of individual properties
inside the <propertygroup>
block.
The second property group is embedded within the first.
The attribute control is set to
select, which provides a
drop-down list.
The attribute options defines
the available options.
The attribute visibleon
indicates that the properties in the group are conditional
based on selection from the drop-down.
The callback <onvalidate> within a
<property> block is used to validate
the value entered for a property.
The <propertytable> block is used to create
a table for the entry of property values in tabular format. The properties
Temperature and Pressure
nested inside the <propertytable> blocks create
columns for data entry.