Gui User PDF
Gui User PDF
Abaqus 6.12
GUI Toolkit User’s Manual
Abaqus ID:
Printed on:
Abaqus GUI Toolkit User’s Manual
Abaqus ID:
Printed on:
Legal Notices
CAUTION: This documentation is intended for qualified users who will exercise sound engineering judgment and expertise in the use of the Abaqus
Software. The Abaqus Software is inherently complex, and the examples and procedures in this documentation are not intended to be exhaustive or to apply
to any particular situation. Users are cautioned to satisfy themselves as to the accuracy and results of their analyses.
Dassault Systèmes and its subsidiaries, including Dassault Systèmes Simulia Corp., shall not be responsible for the accuracy or usefulness of any analysis
performed using the Abaqus Software or the procedures, examples, or explanations in this documentation. Dassault Systèmes and its subsidiaries shall not
be responsible for the consequences of any errors or omissions that may appear in this documentation.
The Abaqus Software is available only under license from Dassault Systèmes or its subsidiary and may be used or reproduced only in accordance with the
terms of such license. This documentation is subject to the terms and conditions of either the software license agreement signed by the parties, or, absent
such an agreement, the then current software license agreement to which the documentation relates.
This documentation and the software described in this documentation are subject to change without prior notice.
No part of this documentation may be reproduced or distributed in any form without prior written permission of Dassault Systèmes or its subsidiary.
The Abaqus Software is a product of Dassault Systèmes Simulia Corp., Providence, RI, USA.
© Dassault Systèmes, 2012
Abaqus, the 3DS logo, SIMULIA, CATIA, and Unified FEA are trademarks or registered trademarks of Dassault Systèmes or its subsidiaries in the United
States and/or other countries.
Other company, product, and service names may be trademarks or service marks of their respective owners. For additional information concerning
trademarks, copyrights, and licenses, see the Legal Notices in the Abaqus 6.12 Installation and Licensing Guide.
Abaqus ID:
Printed on:
Locations
SIMULIA Worldwide Headquarters Rising Sun Mills, 166 Valley Street, Providence, RI 02909–2499, Tel: +1 401 276 4400,
Fax: +1 401 276 4408, [email protected], http://www.simulia.com
SIMULIA European Headquarters Stationsplein 8-K, 6221 BT Maastricht, The Netherlands, Tel: +31 43 7999 084,
Fax: +31 43 7999 306, [email protected]
Abaqus ID:
Printed on:
Taiwan Simutech Solution Corporation, Taipei, R.O.C., Tel: +886 2 2507 9550, [email protected]
Thailand WorleyParsons Pte Ltd., Singapore, Tel: +65 6735 8444, [email protected]
Turkey A-Ztech Ltd., Istanbul, Tel: +90 216 361 8850, [email protected]
Abaqus ID:
Printed on:
Preface
This section lists various resources that are available for help with using Abaqus Unified FEA software.
Support
Both technical engineering support (for problems with creating a model or performing an analysis) and
systems support (for installation, licensing, and hardware-related problems) for Abaqus are offered through
a network of local support offices. Regional contact information is listed in the front of each Abaqus manual
and is accessible from the Locations page at www.simulia.com.
Training
All offices and representatives offer regularly scheduled public training classes. The courses are offered in
a traditional classroom form and via the Web. We also provide training seminars at customer sites. All
training classes and seminars include workshops to provide as much practical experience with Abaqus as
possible. For a schedule and descriptions of available classes, see www.simulia.com or call your local office
or representative.
Feedback
We welcome any suggestions for improvements to Abaqus software, the support program, or documentation.
We will ensure that any enhancement requests you make are considered for future releases. If you wish to
make a suggestion about the service or products, refer to www.simulia.com. Complaints should be made by
contacting your local office or through www.simulia.com by visiting the Quality Assurance section of the
Support page.
Abaqus ID:
Printed on:
CONTENTS
Contents
PART I OVERVIEW
1. Introduction
What can I do with the Abaqus GUI Toolkit? 1.1
Prerequisites for using the Abaqus GUI Toolkit 1.2
Abaqus GUI Toolkit basics 1.3
Organization of the Abaqus GUI Toolkit User’s Manual 1.4
3. Widgets
Labels and buttons 3.1
Text widgets 3.2
Lists and combo boxes 3.3
Range widgets 3.4
Tree widgets 3.5
Table widget 3.6
Miscellaneous widgets 3.7
The create method 3.8
Widgets and fonts 3.9
4. Layout managers
An overview of layout managers 4.1
Padding and spacing 4.2
Horizontal and vertical frames 4.3
Abaqus ID:cus-toc
Printed on: Sun January 15 -- 12:27:34 2012
CONTENTS
5. Dialog boxes
6. Commands
7. Modes
ii
Abaqus ID:cus-toc
Printed on: Sun January 15 -- 12:27:34 2012
CONTENTS
iii
Abaqus ID:cus-toc
Printed on: Sun January 15 -- 12:27:34 2012
CONTENTS
A. Icons
C. Layout hints
iv
Abaqus ID:cus-toc
Printed on: Sun January 15 -- 12:27:34 2012
Abaqus ID:
Printed on:
Part I: Overview
This part provides an overview of the Abaqus GUI Toolkit and how you use the toolkit to create a customized
application. This part also describes the layout of this manual. The following topic is covered:
• Chapter 1, “Introduction”
Abaqus ID:
Printed on:
WHAT CAN I DO WITH THE Abaqus GUI Toolkit?
1. Introduction
This chapter provides an overview of the Abaqus GUI Toolkit. The Abaqus GUI Toolkit is one of
the Abaqus Process Automation tools that allow you to modify and extend the capabilities of the
Abaqus/CAE graphical user interface (GUI) to enable a wide range of users to generate more efficient
Abaqus solutions. The following topics are covered:
• “What can I do with the Abaqus GUI Toolkit?,” Section 1.1
• “Prerequisites for using the Abaqus GUI Toolkit,” Section 1.2
• “Abaqus GUI Toolkit basics,” Section 1.3
• “Organization of the Abaqus GUI Toolkit User’s Manual,” Section 1.4
1–1
Abaqus ID:
Printed on:
Abaqus GUI Toolkit BASICS
• Remove some top-level menus or some items in those top-level menus. For example, you could
remove the entire top-level Viewport menu to prevent users from manipulating viewports, or you
could remove the Import and Export menu items from the File menu.
• Perform limited changes to Abaqus/CAE GUI modules and toolsets. For more information, see
“Modifying and accessing Abaqus/CAE GUI modules and toolsets,” Section 10.1.
The Abaqus GUI Toolkit is not designed to run outside of Abaqus/CAE; it must be used with
Abaqus/CAE in order for the infrastructure to function properly.
Object-oriented programming
Python is an object-oriented language, and writing an application generally consists of deriving your
own new classes, writing methods for them, and manipulating their data. You should understand
the concepts of object-oriented programming.
GUI design
Depending on the complexity of your application, it may be helpful to have some training in user-
interface design and usability testing. This will help you create an application that is both intuitive
and easy to use.
Abaqus offers training classes that cover Python, kernel scripting, and GUI design. For more information,
contact your local sales office. Training in GUI design is also available from a number of independent
training organizations.
1–2
Abaqus ID:
Printed on:
ORGANIZATION OF THE Abaqus GUI Toolkit USER’S MANUAL
independent, once you write an application for one platform, you can run that application on all supported
platforms—you do not need to change your source code.
The user interface produced by the Abaqus GUI Toolkit looks similar on all platforms. This is due
to the architecture of the toolkit. While the application programming interface (API) is the same on all
platforms, the underlying calls made to the operating system’s GUI libraries differ—on Linux systems
calls are made to the Xt library, whereas on Windows systems calls are made to the Win32 library.
These differences are hidden from the application developer.
Since the FOX GUI Toolkit is object oriented, it allows developers to extend its functionality easily
by deriving new classes from the base toolkit. The Abaqus GUI Toolkit takes advantage of this feature
by adding special functionality required for Abaqus GUIs. Class names that begin with FX are part of
the standard FOX library; for example, FXButton. Class names that begin with AFX are part of the
Abaqus extensions to the FOX library; for example, AFXDialog. When the same class exists with both
the FX and AFX prefix (for example, FXTable and AFXTable), you should use the AFX version since
it provides enhanced functionality for building applications using Abaqus.
Layout managers
This section describes how to use the various layout managers in the Abaqus GUI Toolkit to arrange
widgets in a dialog box.
Dialog boxes
This section describes the dialog boxes that you can create using the Abaqus GUI Toolkit.
Commands
In an application that employs a graphical user interface, the interface must collect input from
the user and communicate that input to the application. In addition, the graphical user interface
must keep its state up-to-date based on the state of the application. This section describes how
1–3
Abaqus ID:
Printed on:
ORGANIZATION OF THE Abaqus GUI Toolkit USER’S MANUAL
those tasks are accomplished using the Abaqus GUI Toolkit and the two types of commands in
Abaqus/CAE—kernel commands and GUI commands.
Modes
A mode is a mechanism for gathering input from the user, processing that input, and then
issuing a command to the kernel. This section describes the modes that are available in the
Abaqus GUI Toolkit.
Creating an application
This section explains how to create an application, such as Abaqus/CAE. It also describes the high-
level infrastructure that is responsible for running the application.
1–4
Abaqus ID:
Printed on:
Part II: Getting Started
This part describes an application that uses the Abaqus GUI Toolkit. This part also describes how you can
use the Abaqus GUI Toolkit to create plug-ins. The following topic is covered:
• Chapter 2, “Getting started with the Abaqus GUI Toolkit”
Abaqus ID:
Printed on:
WHAT ARE THE COMPONENTS OF AN Abaqus GUI APPLICATION?
Widgets
At the lowest level of an application, you use widgets to collect input from the user through a
graphical user interface. For example, a text field widget presents a box into which the user can
type numbers. Similarly, a check button widget presents a small box that the user can click on to
toggle an option on or off.
Layout managers
Layout managers arrange widgets by providing alignment options. For example, a horizontal frame
arranges widgets in a row. A vertical frame arranges widgets in a column.
2–1
Abaqus ID:
Printed on:
WHAT ARE THE COMPONENTS OF AN Abaqus GUI APPLICATION?
Dialog boxes
Dialog boxes group widgets inside layout managers and present all the inputs required for a
particular function. For example, the Print dialog box presents all the controls that allow the user
to specify what should be printed and how it should be printed.
Modes
Modes are GUI mechanisms that control the display of a particular user interface. Modes are also
responsible for issuing the command associated with that user interface. For example, a mode is
started when you select File→Print. This mode posts the Print dialog box and issues the print
command when the user clicks OK.
2–2
Abaqus ID:
Printed on:
PLUG-INS AND CUSTOMIZED APPLICATIONS
be used by one or more GUI modules. The Datum tools in Abaqus/CAE are an example of a GUI
toolset.
The application
The application is responsible for high-level activities, such as managing the GUI process used by
the application and updating the state of the widgets. In addition, the application is responsible for
interacting with the desktop’s window manager.
2–3
Abaqus ID:
Printed on:
Part III: Building dialog boxes
This part describes the components of a dialog box and how you create the components using the
Abaqus GUI Toolkit. The following topics are covered:
• Chapter 3, “Widgets”
• Chapter 4, “Layout managers”
• Chapter 5, “Dialog boxes”
Abaqus ID:
Printed on:
LABELS AND BUTTONS
3. Widgets
This section describes how you can create widgets in your application. There are many widgets in the
Abaqus GUI Toolkit; however, only the most commonly used widgets are described here. You should
refer to the Abaqus GUI Toolkit Reference Manual for a complete listing of widget classes. The following
topics are covered:
3–1
Abaqus ID:
Printed on:
LABELS AND BUTTONS
Tip text
The text displayed when the cursor is held over the widget for a short period of time. If there is only
an icon associated with a widget, you must supply the tip text.
Help text
The text displayed in the application’s status bar, assuming that the application has a status bar.
In addition, you can define a keyboard accelerator for the widget by preceding one of the characters in
the text with an ampersand (&) character. For example, if you specify the string &Calculate for a
button, the button label will appear as shown in Figure 3–1. You can use the accelerator to invoke the
button by pressing the [ Alt] key along with the [C] key.
3.1.2 Labels
The FXLabel widget displays a read-only string. FXLabel can also display an optional icon.
FXLabel(parent, 'This is an FXLabel.\tThis is\nthe tooltip')
3–2
Abaqus ID:
Printed on:
LABELS AND BUTTONS
3–3
Abaqus ID:
Printed on:
LABELS AND BUTTONS
3–4
Abaqus ID:
Printed on:
LABELS AND BUTTONS
form2, AFXMode.ID_ACTIVATE)
In addition to specifying a mnemonic using the & syntax described in “Labels and buttons,”
Section 3.1, you can specify an accelerator in the menu item’s label. You specify an accelerator by
separating it from the button’s text by a \t. For example,
AFXMenuCommand(self, menu, 'Graphics Options...\tCtrl+G', None,
GraphicsOptionsForm(self), AFXMode.ID_ACTIVATE)
...
self.menuPane = None
3–5
Abaqus ID:
Printed on:
LABELS AND BUTTONS
...
if not self.menuPane:
self.menuPane = FXMenuPane(self)
FXMenuCommand(self.menuPane, 'Test1', None, self,
self.ID_TEST1)
FXMenuCommand(self.menuPane, 'Test2', None, self,
self.ID_TEST2)
self.menuPane.create()
return 1
Note: The AFXTable has its own popup menu commands that you should use in place of the approach
described in this section.
3–6
Abaqus ID:
Printed on:
LABELS AND BUTTONS
When connected to an AFXStringKeyword, this widget will assign the value of the button’s
current color to the keyword in hex format; for example, "#FF0000".
3–7
Abaqus ID:
Printed on:
TEXT WIDGETS
This section describes the widgets in the Abaqus GUI Toolkit that allow the user to input text. The
following topics are covered:
• “Single line text field widget,” Section 3.2.1
• “Multi-line text widget,” Section 3.2.2
Text fields are generally connected to keywords, and the type of the keyword determines the type
of input allowed in the text field. For example, if the text field is connected to an integer keyword, the
keyword will verify that the input in the text field is a valid integer. You do not need to specifiy any option
flags for the text field to get this behavior. Complex text fields are an exception to this—to display the
extra field needed to collect complex input, you must specify the bit flag shown in the following example:
AFXTextField(parent, 8, 'Complex AFXTextField',
None, 0, AFXTEXTFIELD_COMPLEX)
3–8
Abaqus ID:
Printed on:
TEXT WIDGETS
Toggled variation
In many cases a check button precedes a labeled text field. The check button allows the user
to toggle the component on or off; when the component is toggled off, the text field becomes
disabled. The AFXTextField widget creates a check button with this behavior when you supply
the AFXTEXTFIELD_CHECKBUTTON flag. The following example creates a check button with
a text field. It also configures the widget in a vertical orientation so that the label is above the text
field.
AFXTextField(parent, 8, 'AFXTextField', None, 0,
AFXTEXTFIELD_CHECKBUTTON|AFXTEXTFIELD_VERTICAL)
Figure 3–12 An example of a check button with a labeled text field from AFXTextField.
Non-editable variation
In some cases you may want to change the behavior of a text field so that it cannot be edited
by the user; for example, when a particular check button in the dialog box is not set. In this
case, you can make the text field non-editable when the check button is unset by calling the
setEditable(False) method of the AFXTextField widget.
Read-only variation
In some cases you may want to change the behavior of a text field so that it cannot be edited by the
user and appears as a label, making it clear that the user cannot change its contents. For example,
when you are using the Load module in Abaqus/CAE, there are some values that you can specify
in the analysis step in which the load was created but you cannot change in subsequent steps. The
AFXTextField widget supports a read-only state through the setReadOnlyState method.
For example,
tf = AFXTextField(parent, 8,
'String AFXTextField in read-only mode:', keyword)
tf.setReadOnlyState(True)
3–9
Abaqus ID:
Printed on:
LISTS AND COMBO BOXES
This section describes the widgets in the Abaqus GUI Toolkit that allow you to choose one or more items
from a list.
• You use a list widget when there is enough room in the GUI and when it is helpful to display all or
most of the choices at the same time.
• You use a combo box to conserve space in the GUI and when it is preferable to display only the
current choice.
The following topics are covered:
• “Lists,” Section 3.3.1
• “Combo boxes,” Section 3.3.2
• “List boxes,” Section 3.3.3
3.3.1 Lists
AFXList allows one or more selections from its items.
The list created by AFXList supports the following selection policies:
LIST_SINGLESELECT
The user can select zero or one items.
LIST_BROWSESELECT
One item is always selected.
LIST_MULTIPLESELECT
The user can select zero or more items.
3–10
Abaqus ID:
Printed on:
LISTS AND COMBO BOXES
LIST_EXTENDEDSELECT
The user can select zero or more items; drag-, shift-, and control-selections are allowed.
The AFXDialog base class has special code designed to handle double-click messages from a list.
If the user double-clicks in a list, the dialog box first attempts to call the Apply button message handler. If
the Apply button message handler is not found, the dialog attempts to call the Continue button message
handler. If the Continue button message handler is not found, the dialog attempts to call the OK button
message handler. As a result, you do not need to do anything in your script to get this behavior.
However, if you have special double-click processing needs, you can turn off this double-click
behavior by specifying AFXLIST_NO_AUTOCOMMIT as one of the list’s option flags. If you turn off
the double-click behavior, you must catch the SEL_DOUBLECLICKED message from the list in your
dialog box and handle it appropriately.
Note: Because the list may be used in combination with other types of widgets, the list does not draw
a border around itself. As a result, if you want a border around the list, you must provide the border by
placing the list inside some other widget, such as a frame. If you do not want a horizontal scrollbar, use
the HSCROLLING_OFF flag; this flag forces the list to size its width to fit its widest item.
The following is an example of a list within a vertical frame:
vf = FXVerticalFrame(parent, FRAME_THICK|FRAME_SUNKEN,
0, 0, 0, 0, 0, 0, 0, 0)
list = AFXList(vf, 3, tgt, sel, LIST_BROWSESELECT|HSCROLLING_OFF)
list.appendItem('Thin')
list.appendItem('Medium')
list.appendItem('Thick')
3–11
Abaqus ID:
Printed on:
RANGE WIDGETS
This section describes the widgets in the Abaqus GUI Toolkit that allow the user to specify a value within
certain bounds. The following topics are covered:
• “Sliders,” Section 3.4.1
• “Spinners,” Section 3.4.2
3.4.1 Sliders
The AFXSlider widget provides a handle that the user can drag to set a value using only the mouse.
AFXSlider extends the capability of the FXSlider widget by providing the following:
• An optional title.
3–12
Abaqus ID:
Printed on:
TREE WIDGETS
3.4.2 Spinners
The AFXSpinner widget combines a text field and two arrow buttons. The arrows increment the
integer value shown in the text field. AFXSpinner extends the capability of the FXSpinner widget
by providing an optional label. For example,
spinner = AFXSpinner(p, 4, 'AFXSpinner:')
spinner.setRange(20, 80)
spinner.setValue(50)
The AFXFloatSpinner widget is similar to the AFXSpinner widget, but it allows floating
point values.
This section describes the tree widgets in the Abaqus GUI Toolkit. A tree widget arranges its children in
a hierarchical fashion and allows the various branches to be expanded or collapsed. A file browser such
3–13
Abaqus ID:
Printed on:
TREE WIDGETS
as Microsoft Windows Explorer is a common example of an application that makes use of a tree widget.
The following topics are covered:
• “Tree list,” Section 3.5.1
• “Option tree list,” Section 3.5.2
opts
The option flags that you can specify in the tree constructor are shown in the following table:
Option flag Effect
TREELIST_NORMAL (default) TREELIST_EXTENDEDSELECT
TREELIST_EXTENDEDSELECT Extended selection mode allows the user to
drag-select ranges of items.
TREELIST_SINGLESELECT Single selection mode allows the user to
select up to one item.
TREELIST_BROWSESELECT Browse selection mode enforces one single
item to be selected at all times.
TREELIST_MULTIPLESELECT Multiple selection mode is used for selection
of individual items.
TREELIST_AUTOSELECT Automatically select under cursor.
3–14
Abaqus ID:
Printed on:
TREE WIDGETS
vf = FXVerticalFrame(gb, FRAME_SUNKEN|FRAME_THICK,
0,0,0,0, 0,0,0,0)
tree = FXTreeList(vf, 5, None, 0,
LAYOUT_FILL_X|LAYOUT_FILL_Y|
TREELIST_SHOWS_BOXES|TREELIST_ROOT_BOXES|
TREELIST_SHOWS_LINES|TREELIST_BROWSESELECT)
You add an item to a tree by supplying a parent and a text label. You begin by adding root items to
the tree. Root items have a parent of None. The Abaqus GUI Toolkit provides several ways of adding
items to a tree; however, the most convenient approach uses the addItemLast method, as shown in
the following example:
vf = FXVerticalFrame(gb, FRAME_SUNKEN|FRAME_THICK,
0,0,0,0, 0,0,0,0)
self.tree = FXTreeList(vf, 5, None, 0,
LAYOUT_FILL_X|LAYOUT_FILL_Y|
TREELIST_SHOWS_BOXES|TREELIST_ROOT_BOXES|
TREELIST_SHOWS_LINES|TREELIST_BROWSESELECT)
option1 = self.tree.addItemLast(None, 'Option 1')
self.tree.addItemLast(option1, 'Option 1a')
self.tree.addItemLast(option1, 'Option 1b')
option2 = self.tree.addItemLast(None, 'Option 2')
self.tree.addItemLast(option2, 'Option 2a')
option2b = self.tree.addItemLast(option2, 'Option 2b')
self.tree.addItemLast(option2b, 'Option 2bi')
option3 = self.tree.addItemLast(None, 'Option 3')
3–15
Abaqus ID:
Printed on:
TREE WIDGETS
You can also specify icons to be used for each tree item. The “open” icon is displayed next to an
item when it is selected; the “closed” icon is displayed when the item is not selected. These icons are not
associated with the expanded/collapsed state of a branch. For example, Microsoft’s Windows Explorer
uses open and closed folder icons to show the selected state.
You can check if an item is selected using the tree’s isItemSelected method. The tree widget
will send its target a SEL_COMMAND message whenever the user clicks on an item. You can handle
this message and then traverse all the items in the tree to find the selected item. The following example
uses a message handler that assumes that the tree is browse-select and allows the user to select only one
item at a time:
w = self.tree.getFirstItem()
while(w):
if self.tree.isItemSelected(w):
# Do something here based on
# the selected item, w.
break
if w.getFirst():
w=w.getFirst()
continue
while not w.getNext() and w.getParent():
w=w.getParent()
w=w.getNext()
3–16
Abaqus ID:
Printed on:
TABLE WIDGET
tree = AFXOptionTreeList(parent, 6)
tree.addItemLast('Item 1')
item = tree.addItemLast('Item 2')
item.addItemLast('Item 3')
item.addItemLast('Item 4')
item.addItemLast('Item 5')
The AFXTable widget arranges items in rows and columns, similar to a spreadsheet. The table can
have leading rows and columns, which serve as headings. Figure 3–21 shows an example of how the
Abaqus GUI Toolkit lays out a table.
3–17
Abaqus ID:
Printed on:
TABLE WIDGET
leading row
items
leading column
The AFXTable widget has many options and methods that allow a lot of flexibility when you
are trying to configure a table for specific purposes. These options and methods are discussed in the
following sections. The following topics are covered:
• “Table constructor,” Section 3.6.1
• “Rows and columns,” Section 3.6.2
• “Spanning,” Section 3.6.3
• “Justification,” Section 3.6.4
• “Editing,” Section 3.6.5
• “Types,” Section 3.6.6
• “List type,” Section 3.6.7
• “Boolean type,” Section 3.6.8
• “Icon type,” Section 3.6.9
• “ Color type,” Section 3.6.10
• “Popup menu,” Section 3.6.11
• “Colors,” Section 3.6.12
• “Sorting,” Section 3.6.13
3–18
Abaqus ID:
Printed on:
TABLE WIDGET
parent
The first argument in the constructor is the parent. An AFXTable does not draw a frame around
itself; therefore, you may want to create an FXVerticalFrame to use as the parent of the table.
You should zero out the padding in the frame so that the frame wraps tightly around the table.
opts
The option flags that you can specify in the table constructor are shown in the following table:
3–19
Abaqus ID:
Printed on:
TABLE WIDGET
By default, the user can select multiple items in a table. To change this behavior, you should
use the appropriate flag to specify either single select mode or browse select mode. In addition, you
can specify whether the entire row should be selected when the user selects any item in the row.
Abaqus/CAE exhibits this behavior in manager dialogs that contain more than one column.
The following statements creates a table with default settings:
# Tables do not draw a frame around their border.
# Therefore, add a frame widget with zero padding.
vf = FXVerticalFrame(gb, FRAME_SUNKEN|FRAME_THICK,
0,0,0,0, 0,0,0,0)
table = AFXTable(vf, 4, 2, 4, 2)
3–20
Abaqus ID:
Printed on:
TABLE WIDGET
The number of rows and columns that you specify in the table constructor are the total number of
rows and columns, including the leading rows and columns. By default, the table has no leading rows or
columns—you must set the leading rows and columns after the table is constructed using the appropriate
table methods. You can also specify the labels to be displayed in these rows and columns. If you do not
specify any labels for a leading row or column, it will be numbered automatically. You can set more than
one label at once in a heading by using “\t” to separate the labels in a single string.
By default, no grid lines are drawn around items. You can control the visibility of the horizontal
and vertical grid lines individually by using the following table methods:
showHorizontalGrid(True|False)
showVerticalGrid(True|False)
By default, the height of the rows is determined by the font being used for the table. The default width
of a column is 100 pixels. You can override these values using the following table methods:
setRowHeight( row, height) # Height is in pixels
setColumnWidth(column, width) # Width is in pixels
The following example illustrates the use of some of these methods:
vf = FXVerticalFrame(parent, FRAME_SUNKEN|FRAME_THICK,
0,0,0,0,0,0,0,0)
table = AFXTable(vf, 4, 3, 4, 3)
table.setLeadingColumns(1)
table.setLeadingRows(1)
table.setLeadingRowLabels('X\tY')
table.showHorizontalGrid(True)
table.showVerticalGrid(True)
table.setColumnWidth(0, 30)
3.6.3 Spanning
You can make an item in a header row or column span more than one row or column, as shown in the
following example:
vf = FXVerticalFrame(parent, FRAME_SUNKEN|FRAME_THICK,
0,0,0,0, 0,0,0,0)
3–21
Abaqus ID:
Printed on:
TABLE WIDGET
table = AFXTable(vf, 4, 3, 4, 3)
table.setLeadingColumns(1)
table.setLeadingRows(2)
# Corner item
table.setItemSpan(0, 0, 2, 1)
table.showHorizontalGrid(True)
table.showVerticalGrid(True)
table.setColumnWidth(0, 30)
3.6.4 Justification
By default, the table displays entries left justified. You can change how items are justified by using the
following table methods:
setColumnJustify(column, justify)
setItemJustify(row, column, justify)
If you supply a value of -1 for the column number, the setColumn* methods apply the setting to all
columns in the table.
The following table shows the possible values for the justify argument:
Option flag Effect
AFXTable .LEFT Align items to the left side of the cell.
AFXTable .CENTER Center items horizontally.
3–22
Abaqus ID:
Printed on:
TABLE WIDGET
The following example shows how you can change the justification:
vf = FXVerticalFrame(gb, FRAME_SUNKEN|FRAME_THICK,
0,0,0,0, 0,0,0,0)
table = AFXTable(vf, 4, 3, 4, 3)
table.setLeadingColumns(1)
table.setLeadingRows(1)
table.setLeadingRowLabels('X\tY')
table.showHorizontalGrid(True)
table.showVerticalGrid(True)
table.setColumnWidth(0, 30)
3.6.5 Editing
By default, no items in a table are editable. To make all items in a table editable, you must specify
AFXTABLE_EDITABLE in the table constructor. To change the editability of some items in a table,
you can use the following table methods:
setColumnEditable(column, True|False)
setItemEditable(row, column, True|False)
3–23
Abaqus ID:
Printed on:
TABLE WIDGET
3.6.6 Types
By default, all items in a table are text items. However, the table widget also supports the other types of
items shown in the following table:
Type Effect
BOOL Item shows an icon, clicking on it toggles between a true and false icon.
COLOR Item shows a color button
FLOAT Item shows text, a text field is used to edit the value
ICON Item shows an icon, it is not editable.
INT Item shows text, a text field is used to edit the value
LIST Item shows text, a combo box is used to edit the value.
TEXT Item shows text, a text field is used to edit the value.
You can change the type of a column or the type of an individual item using the following table methods:
setColumnType(column, type)
setItemType(row, column, type)
Setting the type to FLOAT or INT does not affect data entry to the table; the user may enter anything
into these types of items (this allows for expression evaluation). However, when using the table’s
getItemIntValue or getItemFloatValue methods you should be sure that the type of the item
that you are reading is INT or FLOAT, respectively, or the wrong value may be returned. In general,
you should make use of the AFXTableKeyword and set the column types so that the table’s values are
automatically evaluated correctly.
3–24
Abaqus ID:
Printed on:
TABLE WIDGET
table.showHorizontalGrid(True)
table.showVerticalGrid(True)
listId = table.addList('Small\tMedium\tLarge')
table.setColumnType(0, AFXTable.LIST)
table.setColumnListId(0, listId)
You can also add list items that contain icons using the appendListItem method of the table.
icon = createGIFIcon('myIcon.gif')
table.appendListItem(listId, 'Extra large', icon)
When you connect a table keyword to a table that contains lists, you must set the column type
of the table keyword appropriately. If the list contains only text, you can set the column type to
AFXTABLE_TYPE_STRING, which sets the value of the keyword to the text of the item selected in the
list. Similarly, if the list contains only icons, you can set the column type to AFXTABLE_TYPE_INT,
which sets the value of the keyword to the index of the item selected in the list. If the list contains both
text and icons, you can use either setting for the column type.
3–25
Abaqus ID:
Printed on:
TABLE WIDGET
table.setColumnType(0, table.BOOL)
table.setColumnWidth(0, 50)
table.setColumnJustify(0, AFXTable.CENTER)
If you do not want to use the default icons, you can set your own true and false icons, as shown in
the following example:
vf = FXVerticalFrame(gb, FRAME_SUNKEN|FRAME_THICK,
0,0,0,0, 0,0,0,0)
table = AFXTable(vf, 4, 2, 4, 2, None, 0,
AFXTABLE_NORMAL|AFXTABLE_EDITABLE)
table.setLeadingRows(1)
table.setLeadingRowLabels('State\tLayer')
table.showHorizontalGrid(True)
table.showVerticalGrid(True)
table.setColumnType(0, table.BOOL)
table.setColumnWidth(0, 50)
table.setColumnJustify(0, AFXTable.CENTER)
3–26
Abaqus ID:
Printed on:
TABLE WIDGET
3–27
Abaqus ID:
Printed on:
TABLE WIDGET
and one for an “as-is” color. Refer to the Color Code dialog box in Abaqus/CAE to see examples of how
these options may be used. The options are specified using the flags in the following table:
The following example shows how you can display color buttons in a table:
vf = FXVerticalFrame(
gb, FRAME_SUNKEN|FRAME_THICK, 0,0,0,0, 0,0,0,0)
table = AFXTable(
vf, 4, 2, 4, 2, None, 0, AFXTABLE_NORMAL|AFXTABLE_EDITABLE)
table.setLeadingRows(1)
table.setLeadingRowLabels('Name\tColor')
table.setColumnType(1,AFXTable.COLOR)
table.setColumnColorOptions(
1, AFXTable.COLOR_INCLUDE_COLOR_ONLY)
table.setItemText(1, 0, 'Part-1')
table.setItemText(2, 0, 'Part-2')
table.setItemText(3, 0, 'Part-3')
table.setItemColor(1,1, '#FF0000')
table.setItemColor(2,1, '#00FF00')
table.setItemColor(3,1, '#0000FF')
3–28
Abaqus ID:
Printed on:
TABLE WIDGET
You can also add a custom button to the popup menu by using the table’s appendClientPopupItem
method, as shown in Figure 3–31. The following example shows how you can enable various popup
menu options:
3–29
Abaqus ID:
Printed on:
TABLE WIDGET
vf = FXVerticalFrame(parent, FRAME_SUNKEN|FRAME_THICK,
0,0,0,0, 0,0,0,0)
table = AFXTable(vf, 4, 3, 4, 3, None, 0,
AFXTABLE_NORMAL|AFXTABLE_EDITABLE)
table.setLeadingColumns(1)
table.setLeadingRows(1)
table.setLeadingRowLabels('X\tY')
table.showHorizontalGrid(True)
table.showVerticalGrid(True)
table.setColumnWidth(0, 30)
table.setPopupOptions(
AFXTable.POPUP_CUT|AFXTable.POPUP_COPY
|AFXTable.POPUP_PASTE
|AFXTable.POPUP_INSERT_ROW
|AFXTable.POPUP_DELETE_ROW
|AFXTable.POPUP_CLEAR_CONTENTS
3–30
Abaqus ID:
Printed on:
TABLE WIDGET
|AFXTable.POPUP_READ_FROM_FILE
)
table.appendClientPopupItem('My Button', None, self,
self.ID_MY_BUTTON)
FXMAPFUNC(self, SEL_COMMAND, self.ID_MY_BUTTON, MyDB.onCmdMyBtn)
3.6.12 Colors
Items in a table that display characters have two sets of colors—the normal color and the selected color.
In addition, each item has a background color and a text color. To change these colors, the table widget
provides the following controls:
• Item text color
• Item background color
• Selected item text color
• Selected item background color
• Item color (color button) (The color button is described in “Color buttons,” Section 3.1.10.)
You can control the text color of items that display characters using the setItemTextColor
method. Items that display characters include strings, numbers, and lists. You can control the text color
of these items when they are selected by using the setSelTextColor method. You can control
the background color of any item by using the setItemBackColor method. You can control the
background color of any item when it is selected by using the setSelBackColor method.
If you do not want the colors to change when the user selects an item, you can set the colors used
for items that are selected to be the same as the colors used for items that are not selected. This approach
is shown in the following example:
itemColor = table.getItemBackColor(1,1)
table.setSelBackColor(itemColor)
itemTextColor = table.getItemTextColor(1,1)
table.setSelTextColor(itemTextColor)
You can set colors using the color name or by specifying RGB values using the FXRGB function.
(For a list of valid color names and their corresponding RGB values, see Appendix B, “Colors and RGB
values.”) Both methods are illustrated in the following example:
vf = FXVerticalFrame(parent, FRAME_SUNKEN|FRAME_THICK,
0,0,0,0, 0,0,0,0)
table = AFXTable(vf, 4, 2, 4, 2, None, 0,
AFXTABLE_NORMAL|AFXTABLE_EDITABLE)
table.setLeadingRows(1)
table.setLeadingRowLabels('Name\tDescription')
3–31
Abaqus ID:
Printed on:
TABLE WIDGET
table.showHorizontalGrid(True)
table.showVerticalGrid(True)
table.setItemTextColor(1,0, 'Blue')
table.setItemTextColor(1,1, FXRGB(0, 0, 255))
table.setItemBackColor(3,0, 'Pink')
table.setItemBackColor(3,1, FXRGB(255, 192, 203))
3.6.13 Sorting
You can set a column in a table to be sortable. If a column is set to be sortable and the user clicks on its
heading, a graphic will be displayed in the heading that shows the order of the sort. You must write the
code that performs the actual sorting in the table—the table itself provides only the graphical feedback
in the heading cell. For example:
class MyDB(AFXDataDialog):
def __init(self):
...
# Create a table.
vf = FXVerticalFrame(
parent, FRAME_SUNKEN|FRAME_THICK, 0,0,0,0, 0,0,0,0)
self.sortTable = AFXTable(vf, 4, 3, 4, 3, self,
self.ID_TABLE, AFXTABLE_NORMAL|AFXTABLE_EDITABLE)
3–32
Abaqus ID:
Printed on:
TABLE WIDGET
self.sortTable.setLeadingRows(1)
self.sortTable.setLeadingRowLabels('Name\tX\tY')
self.sortTable.setColumnSortable(1, True)
self.sortTable.setColumnSortable(2, True)
...
values = []
index = 1
for row in range(1, self.sortTable.getNumRows()):
values.append( (self.sortTable.getItemFloatValue(
row, column), index) )
index += 1
values.sort()
if self.sortTable.getColumnSortOrder(column) == \
AFXTable.SORT_ASCENDING:
values.reverse()
items = []
for value, index in values:
name = self.sortTable.getItemValue(index, 0)
xValue = self.sortTable.getItemValue(index, 1)
yValue = self.sortTable.getItemValue(index, 2)
items.append( (name, xValue, yValue) )
row = 1
for name, xValue, yValue in items:
self.sortTable.setItemValue(row, 0, name)
self.sortTable.setItemValue(row, 1, xValue)
self.sortTable.setItemValue(row, 2, yValue)
row += 1
3–33
Abaqus ID:
Printed on:
MISCELLANEOUS WIDGETS
This section describes a set of miscellaneous widgets in the Abaqus GUI Toolkit that you can use in your
applications. The following topics are covered:
• “Separators,” Section 3.7.1
• “Notes and warnings,” Section 3.7.2
• “Progress bar,” Section 3.7.3
3.7.1 Separators
The FXHorizontalSeparator widget and the FXVerticalSeparator widget provide a
visual separator to allow separating elements in a GUI. The Abaqus GUI Toolkit also includes a
FXMenuSeparator widget that you can use to separate items in a menu pane. For example,
3–34
Abaqus ID:
Printed on:
MISCELLANEOUS WIDGETS
If you want to control the display of the progress bar you can use the percentage or iterator mode and
call setProgress with the appropriate value.
from abaqusGui import *
class MyDB(AFXDataDialog):
ID_START = AFXDataDialog.ID_LAST
def __init__(self, form):
AFXDataDialog.__init__(self, form, 'My Dialog',
self.OK|self.CANCEL, DECOR_RESIZE|DIALOG_ACTIONS_SEPARATOR)
FXButton(self, 'Start Something', None, self, self.ID_START)
FXMAPFUNC(self, SEL_COMMAND, self.ID_START, MyDB.onDoSomething)
self.scannerDB = ScannerDB(self)
3–35
Abaqus ID:
Printed on:
THE CREATE METHOD
Note: The setProgress method has no effect on a progress bar that uses the scanner mode.
The progress bar has several different modes, as shown in Figure 3–36.
3–36
Abaqus ID:
Printed on:
WIDGETS AND FONTS
application object’s create method. This call traverses the entire widget hierarchy calling the create
method of each widget. For more information and an example script, see “Startup script,” Section 11.2.
If you create widgets after the startup script has called the application’s create method, the
create method must be called on those new widgets; otherwise, they will not be visible on the screen.
If your dialog box is posted by a form or by a procedure, the infrastructure calls the create()
method on the dialog box. However, if you post a dialog box yourself, you must call the create()
method on the dialog box before you call its show() method.
Similarly, if you construct icons that are used after a widget has been created, you must call the
create() method on those icons before using them in a widget. For example, if you want to change
a label’s icon after it has already been shown in a dialog box, you must do the following:
1. Construct the new icon.
2. Call the new icon’s create() method.
3. Pass the icon to the label using the label’s setIcon() method.
3–37
Abaqus ID:
Printed on:
WIDGETS AND FONTS
• FONT_BOLD
• FONT_ITALIC
• FONT_SMALL
The following example shows how you can change the default font for all widgets and the font for
a particular widget:
3–38
Abaqus ID:
Printed on:
AN OVERVIEW OF LAYOUT MANAGERS
4. Layout managers
This section describes how to use the various layout managers in the Abaqus GUI Toolkit to arrange
widgets in a dialog box. The following topics are covered:
• “An overview of layout managers,” Section 4.1
• “Padding and spacing,” Section 4.2
• “Horizontal and vertical frames,” Section 4.3
• “Vertical alignment for composite children,” Section 4.4
• “General-purpose layout managers,” Section 4.5
• “Row and column layout manager,” Section 4.6
• “Resizable regions,” Section 4.7
• “Rotating regions,” Section 4.8
• “Tab books,” Section 4.9
• “Layout hints,” Section 4.10
• “Layout examples,” Section 4.11
• “Tips for specifying layout hints,” Section 4.12
FXVerticalFrame
Arranges widgets vertically. For more information, see “Horizontal and vertical frames,”
Section 4.3.
AFXVerticalAligner
Vertically aligns the first child of its children. For more information, see “Vertical alignment for
composite children,” Section 4.4.
4–1
Abaqus ID:
Printed on:
PADDING AND SPACING
FXPacker
Arranges widgets in a general manner. For more information, see “General-purpose layout
managers,” Section 4.5.
AFXDialog
Same capabilities as FXPacker. For more information, see “General-purpose layout managers,”
Section 4.5.
FXGroupBox
Same capabilities as FXPacker but allows a titled border. For more information, see “General-
purpose layout managers,” Section 4.5.
FXMatrix
Arranges widgets in rows and columns. For more information, see “Row and column layout
manager,” Section 4.6.
FXSplitter
Splits an area vertically or horizontally, and allows you to resize the areas. For more information,
see “Resizable regions,” Section 4.7.
FXSwitcher
Swaps children on top of each other (rotating regions). For more information, see “Rotating
regions,” Section 4.8.
FXTabBook
Displays one tab, or one page, of widgets at a time. The user selects the tab to view by clicking a
tab button. For more information, see “Tab books,” Section 4.9.
4–2
Abaqus ID:
Printed on:
VERTICAL ALIGNMENT FOR COMPOSITE CHILDREN
4–3
Abaqus ID:
Printed on:
GENERAL-PURPOSE LAYOUT MANAGERS
AFXDialog
AFXDialog provides similar capabilities to FXPacker. As a result, you do not need to provide
a top-level layout manager as the first child in a dialog box; you can use the layout capabilities of
the dialog box instead.
FXGroupBox
FXGroupBox provides the same capabilities as FXPacker. In addition, FXGroupBox can
display a labeled border around its children. Abaqus/CAE uses the FRAME_GROOVE flag to
produce a thin border around the children of the group box.
For example,
4–4
Abaqus ID:
Printed on:
RESIZABLE REGIONS
Figure 4–3 An example of a group box with a labeled border from FXGroupBox.
4–5
Abaqus ID:
Printed on:
ROTATING REGIONS
sp = FXSplitter(parent,
LAYOUT_FILL_X|LAYOUT_FIX_HEIGHT|SPLITTER_VERTICAL,
0,0,0,100)
hf1 = FXHorizontalFrame(sp, FRAME_SUNKEN|FRAME_THICK)
FXLabel(hf1, 'This is area 1')
hf2 = FXHorizontalFrame(sp, FRAME_SUNKEN|FRAME_THICK)
FXLabel(hf2, 'This is area 2')
4–6
Abaqus ID:
Printed on:
TAB BOOKS
4–7
Abaqus ID:
Printed on:
TAB BOOKS
AFXNote(subTab1Frame,
'This is a note\nin sub-tab item 1\nthat extends\n' \
'over several\nlines.')
FXTabItem(tabBook2, 'Subtab Item 2', None, TAB_LEFT)
subTab2Frame = FXHorizontalFrame(tabBook2,
FRAME_RAISED|FRAME_SUNKEN)
4–8
Abaqus ID:
Printed on:
LAYOUT HINTS
LAYOUT_SIDE_BOTTOM
Attaches a widget to the bottom side of the cavity.
LAYOUT_SIDE_LEFT
Attaches a widget to the left side of the cavity.
LAYOUT_SIDE_RIGHT
Attaches a widget to the right side of the cavity.
You should specify only one of the LAYOUT_SIDE_* hints per child. The top and bottom hints
effectively reduce the height of the available space remaining to place other children. The left and right
hints effectively reduce the width of the available space remaining to place other children.
All layout managers support the following layout hints:
• LAYOUT_LEFT (default) and LAYOUT_RIGHT. The layout manager places the widget on the
left or right side of the space remaining in the container.
• LAYOUT_TOP (default) and LAYOUT_BOTTOM. The layout manager places the widget on the
top or bottom side of the space remaining in the container.
• LAYOUT_CENTER_X and LAYOUT_CENTER_Y. The layout manager centers the widget in the
X- or Y-direction in the parent. The manager adds extra spacing around the widget to place it at
the center of the space available to it. The widget’s size will be its default size unless you specify
LAYOUT_FIX_WIDTH or LAYOUT_FIX_HEIGHT.
• LAYOUT_FILL_X and LAYOUT_FILL_Y. You can specify either none, one, or both of these
layout hints. LAYOUT_FILL_X causes the parent layout manager to stretch or to shrink the
widget to accomodate the available space. If you place more than one child with this option side
by side, the manager subdivides the available space proportionally to the children’s default size.
LAYOUT_FILL_Y has the identical effect in the vertical direction.
FXPacker, FXTopWindow, and FXGroupBox must use LAYOUT_LEFT and LAYOUT_RIGHT
with LAYOUT_SIDE_TOP and LAYOUT_SIDE_BOTTOM. The Abaqus GUI Toolkit ignores
hints if they do not make sense; for example, FXHorizontalFrame ignores LAYOUT_TOP and
LAYOUT_BOTTOM. Similar rules apply for the other hints.
4–9
Abaqus ID:
Printed on:
LAYOUT EXAMPLES
The majority of widgets in the Abaqus GUI Toolkit have width and height arguments in their
constructors. In most cases you can accept the default value of zero for these arguments, which allows
the application to determine the proper size of the widget. However, in some cases you will need to
set specific values for the width and height of a widget. To set the width and height, you must pass the
LAYOUT_FIX_WIDTH and LAYOUT_FIX_HEIGHT flags to the options argument of the widget. If
you do not pass these flags to the options argument, the toolkit will ignore the values that you specified
for the width and height.
Layout hints are described in detail in Appendix C, “Layout hints.”
Example 1
The first example starts by creating a single button on the left side of the cavity. The default value
for the vertical position is LAYOUT_TOP, so the example places the button on the left side and at
the top of the available space.
gb = FXGroupBox(parent, '')
FXButton(gb, 'Button 1', opts=LAYOUT_SIDE_LEFT|BUTTON_NORMAL)
Figure 4–8 Creating a button on the left side and at the top of the layout cavity.
The following statement adds a second button on the left side at the top of the available space:
4–10
Abaqus ID:
Printed on:
LAYOUT EXAMPLES
Figure 4–9 Adding a second button on the left side at the top of the layout cavity.
The following statement adds a third button on the left side at the top of the available space:
FXButton(gb, 'Button 3',
opts=LAYOUT_SIDE_LEFT|BUTTON_NORMAL)
Figure 4–10 Adding a third button on the left side at the top of the layout cavity.
Example 2
The second example illustrates how you can use nondefault layout hints. The example starts by
using the default hints to position a button on top of the available space and on the left.
gb = FXGroupBox(p,'')
FXButton(gb,'Button 1')
4–11
Abaqus ID:
Printed on:
LAYOUT EXAMPLES
Figure 4–12 Creating a button on the left side and at the top of the layout cavity.
The example then positions a second button on the right side on the bottom of the layout cavity.
Figure 4–13 Adding a second button on the right side at the bottom of the layout cavity.
Finally, the example places a third button on the bottom of the available space and centered in the
X-direction.
4–12
Abaqus ID:
Printed on:
TIPS FOR SPECIFYING LAYOUT HINTS
Figure 4–14 Adding a third button in the center at the bottom of the layout cavity.
• Do not over specify layout hints. In many cases the default values are what you want, and you do
not need to specify the hints.
• Think in terms of simple rows and columns, and use horizontal or vertical frames whenever possible.
• To avoid building up excessive padding, set the padding to zero in nested layout managers.
• Layout hints are described in detail in Appendix C, “Layout hints.”
4–13
Abaqus ID:
Printed on:
MODAL VERSUS MODELESS
5. Dialog boxes
This section describes the dialog boxes that you can create using the Abaqus GUI Toolkit. The following
topics are covered:
• “An overview of dialog boxes,” Section 5.1
• “Modal versus modeless,” Section 5.2
• “Showing and hiding dialog boxes,” Section 5.3
• “Message dialog boxes,” Section 5.4
• “Custom dialog boxes,” Section 5.5
• “Data dialog boxes,” Section 5.6
• “Common dialog boxes,” Section 5.7
These dialog boxes, along with other details related to dialog box construction and behavior, are described
in this chapter.
5–1
Abaqus ID:
Printed on:
SHOWING AND HIDING DIALOG BOXES
Modal
A modal dialog box prevents interaction with the rest of the application until the user dismisses the
dialog box.
Modeless
A modeless dialog box allows the user to interact with other parts of the GUI while the dialog box
is posted. In Abaqus/CAE all secondary dialog boxes except for tips should be modal dialog boxes.
A dialog box itself is not defined as modal or modeless—the behavior is obtained from the method used
to post the dialog box.
For dialog boxes posted by forms, you can set the modal behavior by calling the form’s setModal
method and providing an argument of either True or False. If you call setModal with True as its
argument, the form will post the next dialog box modally. You can call the setModal method several
times within one form if you need to change the modal behavior between the various dialog boxes
managed by the form.
For dialog boxes that you post yourself, you can use the showModal method instead of the show
method described in the next section. “File/Directory selector,” Section 5.7.1 includes an example that
uses the showModal method.
def hide(self):
5–2
Abaqus ID:
Printed on:
MESSAGE DIALOG BOXES
5–3
Abaqus ID:
Printed on:
MESSAGE DIALOG BOXES
...
def doCustomChecks(self):
if <someCondition>:
showAFXWarningDialog( self.getCurrentDialog(),
'Save changes made in the dialog?',
AFXDialog.YES | AFXDialog.NO,
5–4
Abaqus ID:
Printed on:
MESSAGE DIALOG BOXES
self, self.ID_WARNING)
return False
return True
if sender.getPressedButtonId() == \
AFXDialog.ID_CLICKED_YES:
self.issueCommands()
elif sender.getPressedButtonId() == \
AFXDialog.ID_CLICKED_NO:
self.deactivate()
5–5
Abaqus ID:
Printed on:
CUSTOM DIALOG BOXES
AFXDialog is the base class for the other dialog box classes in the toolkit. If none of the other dialog
box classes suit your needs, you must derive your dialog box from AFXDialog and provide most of
the dialog processing yourself. This section describes how you can use AFXDialog to create custom
dialog boxes. The following topics are covered:
• “An overview of custom dialog boxes,” Section 5.5.1
• “Constructors,” Section 5.5.2
• “Sizing and location,” Section 5.5.3
• “Action area,” Section 5.5.4
• “Custom action area button names,” Section 5.5.5
• “Action button handling,” Section 5.5.6
5–6
Abaqus ID:
Printed on:
CUSTOM DIALOG BOXES
5.5.2 Constructors
There are three prototypes of the AFXDialog constructor. The difference between the three prototypes
is the occluding behavior of the dialog box, as illustrated in the following examples:
• The following statement creates a dialog box that always occludes the main window when
overlapping with the main window:
AFXDialog(title, actionButtonIds=0,
opts=DIALOG_NORMAL, x = 0, y = 0, w = 0, h = 0)
• The following statement creates a dialog box that always occludes its owner widget (usually a dialog
box) when overlapping with the widget:
AFXDialog(owner, title, actionButtonIds=0,
opts=DIALOG_NORMAL, x = 0, y = 0, w = 0, h = 0)
• The following statement creates a dialog box that can be occluded by any other windows in the
application:
AFXDialog(app, title, actionButtonIds=0,
opts = DIALOG_NORMAL, x = 0, y = 0, w = 0, h = 0)
When you construct a dialog box, you will start by deriving from the AFXDialog class. The first
thing you should do in the constructor body is call the base class constructor to properly initialize the
dialog. Then, you would build the contents of your dialog by adding widgets. For example:
5–7
Abaqus ID:
Printed on:
CUSTOM DIALOG BOXES
class MyDB(AFXDialog):
# My constructor
def __init__(self):
5–8
Abaqus ID:
Printed on:
CUSTOM DIALOG BOXES
AFXDialog also supports the following options that determine the location of the action area:
DIALOG_ACTIONS_BOTTOM
This option places the action area at the bottom of the dialog box and is the default option.
DIALOG_ACTIONS_RIGHT
This option places the action area on the right side of the dialog box.
DIALOG_ACTIONS_NONE
This option does not create an action area; for example, in a toolbox dialog box.
You can also specify whether a separator should be placed between the action area and the rest of
the dialog box by including the following flag in the options:
DIALOG_ACTIONS_SEPARATOR
The style in Abaqus/CAE is to omit a separator if there is already delineation between the action
area and the rest of the dialog box; for example, a frame that stretches across the entire width of the
dialog box along the bottom of the dialog box. The following statements illustrate how you define
an action area in a dialog box with a separator:
5–9
Abaqus ID:
Printed on:
CUSTOM DIALOG BOXES
class ActionAreaDB(AFXDialog):
def __init__(self):
5–10
Abaqus ID:
Printed on:
DATA DIALOG BOXES
A data dialog box is a dialog box in which data are collected from the user. In contrast, a message dialog
box displays only a message and a toolbox just holds buttons. This section describes how you can create
a data dialog box. The following topics are covered:
• “An overview of data dialog boxes,” Section 5.6.1
• “Constructors,” Section 5.6.2
• “Bailout,” Section 5.6.3
• “Constructor contents,” Section 5.6.4
• “Transitions,” Section 5.6.5
5–11
Abaqus ID:
Printed on:
DATA DIALOG BOXES
if the dialog box belongs to a module or nonpersistent toolset so that the GUI infrastructure can properly
manage the dialog box when the user switches modules.
The AFXDataDialog class is derived from AFXDialog and provides the following additional
features:
• A bailout mechanism.
• Standard action area button behavior designed to work with a form.
• Keyword usage.
• Transitions that define GUI state changes in the dialog box.
5.6.2 Constructors
There are two prototypes of the AFXDataDialog constructor. The difference between the two
prototypes is the occluding behavior of the dialog box, as illustrated in the following examples:
• The following statement creates a dialog box that always occludes the main window when
overlapping with the main window:
AFXDataDialog(mode, title, actionButtonIds=0,
opts=DIALOG_NORMAL, x = 0, y = 0, w = 0, h = 0 )
• The following statement creates a dialog box that always occludes its owner widget (usually a dialog
box) when overlapping with the widget.
AFXDataDialog(mode, owner, title, actionButtonIds=0,
opts=DIALOG_NORMAL, x = 0, y = 0, w = 0, h = 0 )
When you construct a dialog box, you will start by deriving from the AFXDataDialog class. The
first thing you should do in the constructor body is call the base class constructor to properly initialize
the dialog. Then, you would build the contents of your dialog by adding widgets. For example:
class MyDB(AFXDataDialog):
# My constructor
def __init__(self):
5–12
Abaqus ID:
Printed on:
DATA DIALOG BOXES
is unposted. Destroying a dialog box removes only the GUI resources and retains the dialog box’s data
structures.
If there is some dialog box GUI state that you want to retain between postings of the dialog box,
you should specify that the dialog box is destroyed only when it is unposted. Therefore, when the dialog
box is posted again, it retains its data structures and the old state is still intact. For example, assume
that your dialog box contains a table and the user resizes one of the columns of the table. If you only
destroy the dialog box when it is unposted, the table column sizes will be remembered the next time
the dialog box is posted. To specify that a dialog box should be destroyed when unposted, add the
DIALOG_UNPOST_DESTROY flag to the dialog box constructor’s opts argument.
5.6.3 Bailout
AFXDataDialog supports automatic bailout handling through the specification of a bit flag in the
dialog box constructor. If you request bailout processing and the user changes some values in the dialog
box and presses Cancel, the application posts a standard warning dialog box. The following statement
requests bailout processing:
After the standard warning dialog box has been posted, the behavior is as follows:
• If the user clicks Yes from the standard warning dialog box, the data dialog box will be processed
as if the user had originally pressed OK.
• If the user clicks No from the standard warning dialog box, the data dialog box will be unposted
without any processing.
• If the user clicks Cancel from the standard warning dialog box, the data dialog box will remain
posted and no action will be taken.
5–13
Abaqus ID:
Printed on:
DATA DIALOG BOXES
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def __init__(self, form):
# Hardware frame
#
gb = FXGroupBox(self, 'Hardware',
FRAME_GROOVE|LAYOUT_FILL_X)
hardwareFrame = FXHorizontalFrame(gb,
0, 0,0,0,0, 0,0,0,0)
FXLabel(hardwareFrame, 'Driver:')
FXRadioButton(hardwareFrame, 'OpenGL',
form.graphicsDriverKw, OPEN_GL.getId())
FXRadioButton(hardwareFrame, 'X11',
form.graphicsDriverKw, X11.getId())
FXCheckButton(gb, 'Use double buffering',
form.doubleBufferingKw)
displayListBtn = FXCheckButton(gb, 'Use display lists',
form.displayListsKw)
5–14
Abaqus ID:
Printed on:
DATA DIALOG BOXES
5.6.5 Transitions
Transitions provide a convenient way to change the GUI state in a dialog box. Transitions are used to
stipple widgets or to rotate regions when some other control in the dialog box is activated. If the behavior
in your dialog box can be described in terms of simple transitions, you can use the addTransition
method to produce the state changes.
Transitions compare the value of a keyword with a specified value. If the operator condition is met,
a message is sent to the specified target object. Transitions have the following prototype:
addTransition(keyword,
operator, value, tgt, sel, ptr)
For example, when the user selects Wireframe as the render style in the Part Display Options
dialog box, Abaqus/CAE does the following:
• Stipples the Show dotted lines in hidden render style button.
• Stipples the Show edges in shaded render style button.
• Checks the Show silhouette edges button.
5–15
Abaqus ID:
Printed on:
DATA DIALOG BOXES
self.addTransition(form.renderStyleKw, AFXTransition.EQ,
WIREFRAME.getId(), showEdgesBtn,
MKUINT(FXWindow.ID_DISABLE, SEL_COMMAND), None)
self.addTransition(form.renderStyleKw, AFXTransition.EQ,
WIREFRAME.getId(), showSilhouetteBtn,
MKUINT(FXWindow.ID_ENABLE, SEL_COMMAND), None)
You can also pass additional user data to the object using the last argument of the addTransition
method. Figure 5–8 shows an example that uses transitions to control how the application stipples
widgets.
if self.form.kw1.getValue() == 1 and \
self.form.kw2.getValue() == 2:
self.btn1.disable()
else:
self.btn1.enable()
5–16
Abaqus ID:
Printed on:
DATA DIALOG BOXES
Figure 5–8 An example of using transitions to control how the application stipples widgets.
If the tasks you need to perform are time consuming, you should write your own message handler
that is invoked only upon some specific user action. For example, if you need to scan an ODB for valid
data, you could make the commit button of the dialog send a message to your dialog box. That message
would invoke your message handler that does the scanning. That way, the scanning occurs only when the
user commits the dialog, not during every GUI update cycle. For more information on message handlers,
see “Targets and messages,” Section 6.5.4.
5–17
Abaqus ID:
Printed on:
COMMON DIALOG BOXES
Button Action
OK Send the form an (ID_COMMIT, SEL_COMMAND) message and its button ID.
Apply Send the form an (ID_COMMIT, SEL_COMMAND) message and its button ID.
Continue Send the form an (ID_GET_NEXT, SEL_COMMAND) message.
Defaults Send the form an (ID_SET_DEFAULTS, SEL_COMMAND) message.
Cancel Check for bailout, send the form an (ID_DEACTIVATE, SEL_COMMAND) message.
“x” in title bar Perform the Cancel button action.
If your dialog has more than one “apply” button, you can handle this by routing messages from the
button to the apply message handler in the form. In the form, you can use the getPressedButtonId
method to determine which button was pressed and take the appropriate action. For example, in your
dialog constructor:
self.appendActionButton('Plot', self, self.ID_PLOT)
FXMAPFUNC(self, SEL_COMMAND, self.ID_PLOT,
AFXDataDialog.onCmdApply
self.appendActionButton('Highlight', self, self.ID_HIGHLIGHT)
FXMAPFUNC(self, SEL_COMMAND, self.ID_HIGHLIGHT,
AFXDataDialog.onCmdApply)
and in your form code:
def doCustomChecks(self):
if self.getPressedButtonId() == self.getCurrentDialog().ID_PLOT:
# Enable plot commands, disable highlight commands
else:
# Enable highlight commands, disable plot commands
return True
The Abaqus GUI Toolkit provides some pre-built dialog boxes for handling common operations. This
section provides details on how to use these dialog boxes. The following topics are covered:
• “File/Directory selector,” Section 5.7.1
5–18
Abaqus ID:
Printed on:
COMMON DIALOG BOXES
5–19
Abaqus ID:
Printed on:
COMMON DIALOG BOXES
AFXSELECTFILE_MULTIPLE
Allows the selection of multiple existing files only.
AFXSELECTFILE_DIRECTORY
Allows the selection of an existing directory only.
AFXSELECTFILE_REMOTE_HOST
Allows the opening of files on a remote host.
You specify the patterns argument as a series of patterns separated by \n. The value of the target
specified by the patternIndexTgt argument determines which pattern is initially shown when the dialog
box is posted.
The following is an example of how a file selection dialog box can be posted from a form:
def getFirstDialog(self):
if not self.dirDb:
self.dirDb = AFXFileSelectorDialog(self,
'Select a Directory',self.form.dirNameKw,
None, AFXSELECTFILE_DIRECTORY)
self.dirDb.create()
self.dirDb.showModal()
return 1
5–20
Abaqus ID:
Printed on:
COMMON DIALOG BOXES
of the FileToolsetGui class. This can be done by storing a pointer to the form as shown in the following
example:
from sessionGui
import FileToolsetGui
class MyMainWindow(AFXMainWindow):
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def __init__(self, app, windowTitle=''):
...
fileToolset = FileToolsetGui()
self.printForm = fileToolset.getPrintForm()
self.registerToolset(fileToolset,
GUI_IN_MENUBAR|GUI_IN_TOOLBAR)
...
Then you can use the print form in your dialog box class, as shown below:
printForm = getAFXApp().getAFXMainWindow().printForm
FXButton(parent, 'Print...', None, printForm,
AFXMode.ID_ACTIVATE)
To access the print form, you must construct and register the file toolset. However, you cannot
access the print form from within a plug-in. As a result, you can only use the approach described here
in a customized application.
5–21
Abaqus ID:
Printed on:
Part IV: Issuing commands
This part describes how a dialog box can issue commands to the Abaqus/CAE kernel. The following topics
are covered:
• Chapter 6, “Commands”
• Chapter 7, “Modes”
Abaqus ID:
Printed on:
THE KERNEL AND GUI PROCESSES
6. Commands
This section describes the role of commands in the Abaqus GUI toolkit. The following topics are covered:
GUI commands
GUI commands are used by the user interface to process input gathered from the user and to
construct a kernel command string that is sent to the kernel for execution. GUI commands are
documented in the Abaqus GUI Toolkit Reference Manual.
6–1
Abaqus ID:
Printed on:
THE KERNEL AND GUI PROCESSES
GUI process
The GUI is a convenient way for the user to specify input to Abaqus/CAE. A kernel command
string is sent from the GUI process to the kernel process via the inter-process communication (IPC)
protocol. The kernel process interprets and executes the kernel command string. If the kernel
command throws an exception, the exception is propagated back to the GUI process, where it should
be caught and handled properly, typically by posting an error dialog box.
Abaqus/CAE uses an IPC protocol to achieve communication between the kernel and GUI
processes. For example, the GUI often needs to query the kernel for a list of existing part names or for
the values of a particular load that is about to be edited from a dialog box. Similarly, the GUI may need
to be notified when some kernel value changes so that the GUI can update itself; for example, to post
new job messages in the Job Monitor dialog box.
Abaqus/CAE uses targets and messages and the GUI updating process, built into the
Abaqus GUI Toolkit, to achieve communication within the GUI process. For example, an options
dialog box may need to update when the current viewport is changed or some widgets in a dialog box
may need to be grayed out when the user clicks a particular button.
Figure 6–1 illustrates the communication between the kernel and the GUI processes when the user
clicks on a button and then enters values in the dialog box that appears.
Values are sent to GUI Values are set, dialog box is posted
Y
Done Success?
6–2
Abaqus ID:
Printed on:
EXECUTING COMMANDS
6–3
Abaqus ID:
Printed on:
GUI COMMANDS
mdb.models[Model-1'].PointSection(name='Section-3', mass=1.0)
|----- object ------|-- method --|------- arguments --------|
LeafFromElementSets(elementSets='PART-1-1.E1')
|----- method -----|------- arguments -------|
GUI commands are designed to work together with modes. Modes perform the command processing and
send the command to the kernel. For more information, see Chapter 7, “Modes.” This section describes
how to construct and use GUI commands. The following topics are covered:
• “Constructing GUI commands,” Section 6.5.1
• “GUI commands and current objects,” Section 6.5.2
• “Keeping the GUI and commands up-to-date,” Section 6.5.3
6–4
Abaqus ID:
Printed on:
GUI COMMANDS
Procedure modes
Procedure modes provide an interface that guides the user through a sequence of steps by
prompting for input in the prompt area of the application.
method
A String specifying the method of the kernel command.
objectName
A String specifying the object of the kernel command.
6–5
Abaqus ID:
Printed on:
GUI COMMANDS
registerQuery
A Boolean specifying whether or not to register a query on the object.
For example, the following statement creates a command to edit graphics options:
If you have more than one GUI command in a mode, the commands are processed in the same order in
which they are created in the mode. For more examples of creating GUI commands, see “Form example,”
Section 7.3.1, and “Procedure example,” Section 7.4.1.
cmd = AFXGuiCommand(
mode, 'PointSection', 'mdb.models[%s]', True)
6–6
Abaqus ID:
Printed on:
GUI COMMANDS
cmd = AFXGuiCommand(
mode,'bringToFront','session.viewports[%s]', True)
groupBox = FXGroupBox(parent)
groupBox.setTarget(self)
groupBox.setSelector(self.ID_2)
Widgets are capable of sending several types of messages. Two of the most common message types
are SEL_COMMAND and SEL_UPDATE. The SEL_COMMAND message type generally indicates
that a widget was “committed”; for example, the user clicked a push button. The SEL_UPDATE message
is sent when a widget is requesting its target to update its state; for more information, see “Automatic
GUI updating,” Section 6.5.5.
A message is routed to a message handler using a map defined in the target class. You add an entry
in the map by specifying which method to call when a message of a certain type and ID is received.
These concepts are illustrated in Figure 6–2.
The message map is defined by using the FXMAPFUNC function (see example below). This macro
takes four arguments: self, message type, message ID, and method name. The method name must be
qualified by the class name: className.methodName. When a message is received whose type and ID
match those defined in an FXMAPFUNC entry, the corresponding method will be called. If you have a
6–7
Abaqus ID:
Printed on:
GUI COMMANDS
Object 3
(ID_1, msgType1)
Object 1
Target: None
Msg ID: 0
Target: Object 3
Msg Types: Various
Msg ID: ID_1
Msg Types: Various
Message Map:
(msgType1, ID_1, onCmdA)
(msgType2, ID_2, onCmdB)
Object 2 (msgType1, ID_3, onCmdA)
(ID_2, msgType2)
large range of IDs that you want to define in the message map, you can use the FXMAPFUNCS function,
which takes one additional argument: self, message type, start message ID, end message ID, and method
name.
Objects react to messages using message handlers. All message handlers have the same prototype,
which contains the following:
• The sender of the message
• The message selector
• Some “user data”
You can extract the type and ID of the message from the selector using the SELTYPE and SELID
functions.
The following code shows how message maps, message IDs, and message handlers work together:
class MyClass(BaseClass):
[
ID_1,
ID_2,
ID_LAST
] = range(BaseClass.ID_LAST, BaseClass.ID_LAST+3)
def __init__(self):
6–8
Abaqus ID:
Printed on:
GUI COMMANDS
BaseClass.__init__(self)
FXMAPFUNC(self, SEL_COMMAND, self.ID_1,
MyClass.onCmdPrintMsg)
FXMAPFUNC(self, SEL_COMMAND, self.ID_2,
MyClass.onCmdPrintMsg)
if SELID(sel) == self.ID_1:
print 'Button 1 was pressed.'
elif SELID(sel) == self.ID_2:
print 'Button 2 was pressed.'
return 1
The previous example starts by generating a list of IDs for use in the derived class. Since a widget
has a specific target, the ID of a widget does not have to be globally unique; it needs to be unique only
within the target’s class and base classes. To handle this numbering automatically, the convention is to
define ID_LAST in each class. A derived class should begin its numbering using the value of ID_LAST
defined in its base class. In addition, a derived class should define its own ID_LAST as the last ID in
the derived class. A class that derives from the derived class will then be able to make use of that ID to
begin its numbering. ID_LAST should not be used by any widget. The only purpose of ID_LAST is to
provide an automatic numbering scheme between classes.
The example continues by constructing a message map by adding entries using the FXMAPFUNC
function. In this example, when a message of type SEL_COMMAND and an ID of ID_1 or ID_2 is
received, the script calls the onCmdPrintMsg method.
The two button widgets have their target set to self (MyClass). However, when each widget
sends a message, the widget sends a different message ID and the message handler checks the ID to
determine who sent the message. For example, if the user clicks the first button, the button sends a
(ID_1, SEL_COMMAND) message to MyClass. The class’s message map routes that message to the
onCmdPrintMsg method. The onCmdPrintMsg method checks the ID of the incoming message
and prints Button 1 was pressed.
It is important that your message handlers return the proper value to ensure that the GUI is kept
up-to-date. Returning a 1 in a message handler tells the toolkit that the message was handled. In turn,
if a message is handled, the toolkit assumes that something may have changed that requires an update,
and the toolkit initiates a GUI update process. Returning a 0 in a message handler tells the toolkit that
the message was not handled; therefore, the toolkit does not initiate a GUI update process.
Messages are normally sent by the GUI infrastructure as the result of some interaction in the GUI.
However, you can send a message directly to an object by calling its handle method. The handle
6–9
Abaqus ID:
Printed on:
GUI COMMANDS
method takes three arguments: sender, selector, and userData. The sender is generally the object that is
sending the message. The selector is made up of the message ID and the message type. You can use the
MKUINT function to create a selector, for example, MKUINT(ID_1, SEL_COMMAND). The user data
must be None since this feature is not supported in the Abaqus GUI Toolkit.
pull state
In a pull state the widgets are interrogating the application to keep up-to-date.
6–10
Abaqus ID:
Printed on:
GUI COMMANDS
the data target is updated automatically. Conversely, when the application state is updated, the widget
connected to the data target is updated automatically.
As described in “Automatic GUI updating,” Section 6.5.5, widgets can be in a push state or a pull
state.
Push state
In a push state the widgets are collecting and sending user input to the application. Figure 6–3
illustrates how a data target works with a widget that is in a push state. The sequence is as follows:
1. First, the user enters a value of 7 in the text field and then presses Enter.
2. This triggers the text field widget to send an (ID, SEL_COMMAND) message to its
target—the data target.
3. The data target responds by sending the sender—the text field widget—a message requesting
the value in the text field. The data target uses that value to update the value of its data.
ID, SEL_COMMAND
7 Data Target data
ID_GETINTVALUE, SEL_COMMAND
data
The user enters a
value into the text field.
Figure 6–3 A data target with a text field widget in push state.
Pull state
In a pull state the widgets are interrogating the application to keep up-to-date. Figure 6–4 illustrates
how a data target works with a widget that is in a pull state. The sequence is as follows:
1. When the GUI is idle, it initiates a GUI update.
2. The GUI update triggers each widget to send an (ID, SEL_UPDATE) message to its target.
3. In this case the data target responds by sending the sender—the text field widget—a message
telling it to set its value to the value of the data target’s data.
ID, SEL_UPDATE
7 Data Target data
ID_SETINTVALUE, SEL_COMMAND
data
The data target updates
the value in the text field.
Figure 6–4 A data target with a text field widget in a pull state.
6–11
Abaqus ID:
Printed on:
GUI COMMANDS
6–12
Abaqus ID:
Printed on:
GUI COMMANDS
ID1, SEL_UPDATE
Option 1
ID2, SEL_UPDATE
Figure 6–5 A data target operating on three radio buttons in option mode and a pull state.
6.5.8 AFXKeywords
Keywords generate the arguments to a GUI command. These keywords belong to the command, but the
keywords are also stored as members of the mode. As a result, you can easily connect the keywords to
widgets in a dialog box that updates the value of the keywords. For more information, see Chapter 5,
“Dialog boxes.”
AFXKeyword is the base class for keywords in the toolkit. The AFXKeyword class derives from
a data target, so it automatically keeps the GUI and application data synchronized with each other. For
more information, see “Data targets,” Section 6.5.6.
The AFXKeyword class extends the functionality of the FXDataTarget class by holding
additional values, such as the name of the keyword, a default value, and a previous value. The keyword’s
GUI command uses this information to construct a kernel command string.
You can designate a keyword as optional or required. A required keyword is always issued by
the GUI command. An optional keyword, whose values have not changed since the last commit of the
command, is not issued by the GUI command. If none of the keywords has changed since the last commit,
no GUI command will be issued when the mode is committed.
The following types of keywords are supported:
6–13
Abaqus ID:
Printed on:
GUI COMMANDS
6–14
Abaqus ID:
Printed on:
GUI COMMANDS
AFXBoolKeyword.ON_OFF, 0)
self.typeKw = AFXSymConstKeyword(cmd, 'type', True,
SHADED.getId())
self.imageSizeKw = AFXTupleKeyword(cmd, 'imageSize', False,
1, 2, AFXTUPLE_TYPE_FLOAT)
3 + (7 * 22)
2 * 3.1415 * 1.5
125/55.8
The expression will get sent in the command, so it will appear in the replay and journal files, but
once the command is processed in the kernel, only the resultant value gets stored and the expression is
lost.
Expression evaluation is always available with an AFXFloatKeyword, but it is optional
for AFXIntKeyword (the default is to perform expression evaluation). If you connect an
AFXIntKeyword to an AFXList or AFXComboBox and the choices shown in the list or combo box
do not represent numeric values, you must disable expression evaluation. For example:
someCommand(order=2, ...)
6–15
Abaqus ID:
Printed on:
GUI COMMANDS
6–16
Abaqus ID:
Printed on:
GUI COMMANDS
Keyword ID Description
AFXTableKeyword 0 Keyword operates in value mode.
# Integer keyword
#
AFXTextField(self, 8, 'Number of CPUs:', mode.cpusKw, 0)
# Float keyword
#
AFXTextField(self, 8, 'Radius:', mode.radiusKw, 0)
# String keyword
#
AFXTextField(self, 8, 'Name:', mode.nameKw, 0)
6–17
Abaqus ID:
Printed on:
GUI COMMANDS
commands. We could number these choices using integer values from 1 to 3. However, using
integer values would result in a command that is not very readable; for example, renderStyle=2.
Alternatively, if we define symbolic constants for each choice, the command becomes more readable;
for example, renderStyle=HIDDEN. Internally, symbolic constants contain an integer ID that can
be accessed via its getId() method. Symbolic constants can be used in both the GUI and kernel
processes. Typically you should create a module that defines your symbolic constants and then import
that module into both your kernel and GUI scripts.
You can import the SymbolicConstant constructor from the symbolicConstants module. The
constructor takes a single string argument. By convention, the string argument uses all capital letters, with
an underscore between words, and the variable name is the same as the string argument. For example,
from symbolicConstants import SymbolicConstant
AS_IS = SymbolicConstant('AS_IS')
In the case of symbolic constant keywords, you can use a value of zero or the value of the ID of a
symbolic constant for the message ID. Symbolic constants have a unique integer ID that is used to set
the value of symbolic constant keywords along with a string representation that is used in the generation
of the command. To access the integer ID of a symbolic constant, use its getId method.
If the keyword is connected to a list or combo box widget, you should use a value of zero for the
ID in the widget constructor. The AFXList, AFXComboBox, and AFXListBox widgets have been
designed to handle symbolic constant keywords as targets. When items are added to a list or combo box,
a symbolic constant’s ID is passed in as user data. These widgets react by setting their value to the item
whose user data matches the value of their target, as opposed to setting their value to the item whose
index matches the target’s value. The following example illustrates how a combo box can be connected
to a symbolic constant keyword:
combo = AFXComboBox(hwGb, 18, 4, 'Highlight method:',
mode.highlightMethodHintKw, 0)
combo.appendItem('Hardware Overlay', HARDWARE_OVERLAY.getId())
combo.appendItem('Software Overlay', SOFTWARE_OVERLAY.getId())
combo.appendItem('XOR', XOR.getId())
combo.appendItem('Blend', BLEND.getId())
If the keyword is connected to a radio button, you should use the ID of the symbolic constant that
corresponds to that radio button for the message ID. Since the ID of all symbolic constants is greater than
zero, this tells the keyword to operate in option mode. The following example illustrates how symbolic
constant keywords can be used with radio buttons:
from abaqusConstants import *
...
# Modeling Space
#
gb = FXGroupBox(self, 'Modeling Space',
6–18
Abaqus ID:
Printed on:
GUI COMMANDS
FRAME_GROOVE|LAYOUT_FILL_X)
FXRadioButton(gb, '3D', mode.dimensionalityKw,
THREE_D.getId(), LAYOUT_SIDE_LEFT)
FXRadioButton(gb, '2D Planar', mode.dimensionalityKw,
TWO_D_PLANAR.getId(), LAYOUT_SIDE_LEFT)
FXRadioButton(gb, 'Axisymmetric',
mode.dimensionalityKw, AXISYMMETRIC.getId(),
LAYOUT_SIDE_LEFT)
you can connect the tuple keyword to a single text field as follows:
Alternatively, you can use three separate text fields to collect X-, Y-, and Z-inputs. Each of the text field
widgets uses a message ID equal to the element number (1-based) of the tuple to which they correspond.
For example, 1 corresponds to the first element of the tuple; 2 corresponds to the second element in the
tuple, etc. In this case we can connect the keyword to three text fields as follows:
6–19
Abaqus ID:
Printed on:
GUI COMMANDS
In the dialog box you connect the table keyword to a table using a selector value of zero.
table = AFXTable(vf, 6, 3, 6, 3,
form.dataKw, 0, AFXTABLE_NORMAL|AFXTABLE_EDITABLE)
If you have a table in which you are interested in the values of only a single column, you can make
use of the AFXColumnItems object to track selections. For example, if a table contains Name and
Description columns, you might only need the names in the selected rows for your command. In that
case you could use AFXColumnItems to keep a tuple keyword up to date with the names in the selected
rows of the table as shown in the following code:
p = mdb.models['Model-1'].parts['Part-1']
session.viewports['Viewport: 1'].setValues(displayedObject=p)
In this example, in the form you would issue the first command “manually,” and use an object keyword
as part of an AFXGuiCommand to have the second command issued using “p” as the variable name. For
example,
You also use an AFXObjectKeyword in procedures that require picking. For more information, see
“Picking in procedure modes,” Section 7.5.
6–20
Abaqus ID:
Printed on:
ACCESSING KERNEL DATA FROM THE GUI
6.6 AFXTargets
Targets are similar to keywords in that they automatically keep their data synchronized with the GUI;
however, targets do not participate in command processing. Targets are typically used to monitor the
value of some widget in the GUI that is not directly related to a command; for example, selecting the
type of load to create from the Create Load dialog box. The following types of targets are supported:
• AFXIntTarget(initialValue)
• AFXFloatTarget(initialValue)
• AFXStringTarget(initialValue)
6–21
Abaqus ID:
Printed on:
RECEIVING NOTIFICATION OF KERNEL DATA CHANGES
You can query the abaqusGui module mdb and session proxy objects for attributes of objects,
but they cannot be used for arbitrary method calls (repository methods such as keys(), values(),
and items() are allowed). The abaqusGui proxy objects are regularly updated from the kernel, and
accessing them is an in-process function call (fast). However, in some cases the proxy objects can get
out of date. For example, when a script is running the proxy objects are not updated until it ends.
You can use the kernelAccess module mdb and session proxy objects to execute any Abaqus
Scripting Interface kernel command. In addition to querying attributes of the kernel objects, you can
call their methods and obtain any return values as if you were executing the code in the kernel. The
kernelAccess proxy objects are always up-to-date because accessing them calls the kernel object
synchronously, creating inter-process communication (IPC) traffic. This immediate interaction with the
kernel creates a performance disadvantage when you use the kernelAccess proxy objects instead of
the abaqusGui module proxy objects. For example, call the getVolume method of the Part object:
This procedure involves GUI-kernel communication via the IPC mechanism, so it is not
recommended for use where performance is a concern. In other words, you should only use this
procedure for accessing data or calling methods that do not take a “long time” to execute. If performance
does become a problem, you can access the mdb and session objects from the abaqusGui module
instead of the kernelAccess module.
Although you can import the kernelAccess module in a script that is executed before the
application startup script has completed, you cannot query the mdb and session objects until the
application startup script has completed. In other words, you can import the kernelAccess module
in your scripts in code that is executed during the initial construction of the GUI; however, you should
not attempt to access either the mdb or session object until it is needed because of some user interaction
in the GUI. For more information, see “Startup script,” Section 11.2
This section describes how the GUI can be notified when kernel objects and custom kernel objects are
modified outside the GUI process. The following topics are covered:
6–22
Abaqus ID:
Printed on:
RECEIVING NOTIFICATION OF KERNEL DATA CHANGES
In this example, if the user changes the current part, the path to the setValues method is updated to
reflect the new current part. As a result, when the user clicks OK to commit a customized dialog box,
the mode issues a setValues command that modifies the current part.
def onPartsChanged():
print 'The parts repository changed.'
keys = mdb.models['Model-1'].parts.keys()
print 'The new keys are:', keys
mdb.models['Model-1'].parts.registerQuery(onPartsChanged)
In the previous example, if a part is created, deleted, renamed, or edited, the onPartsChanged method
will be called.
The registerQuery method takes an optional second argument that determines whether or not
the callback is called when the query is first registered. By default, this argument is True, and the callback
will be called when the query is first registered. If you specify False as the second argument, the query
callback is not called when the query is first registered. Delaying the query callback can prevent errors
6–23
Abaqus ID:
Printed on:
RECEIVING NOTIFICATION OF KERNEL DATA CHANGES
in certain situations; for more information, see “Using registerQuery on kernelAccess proxy
objects,” Section 6.8.3.
Since registered queries create “traffic” between the kernel and GUI processes, you should
unregister queries when you do not need them. To unregister a query, use the unregisterQuery
method and pass the same arguments that you used in the registerQuery method. In most cases,
you register queries within the show method that you write for your dialog box that needs the queries.
Similarly, you unregister queries within the hide method that you write for your dialog box. If you do
not unregister a query and the query fires when the dialog box is not posted, the application may abort
if the callback tries to modify a widget in the dialog box.
If the user creates, deletes, renames, or edits a part in the following example, the application will
call the onPartsChanged method and update the dialog box:
class MyDialog(AFXDataDialog):
...
def onPartsChanged(self):
def show(self):
def hide(self):
6–24
Abaqus ID:
Printed on:
RECEIVING NOTIFICATION OF KERNEL DATA CHANGES
will not matter. However, it can cause a problem if the query is registered while a change is being made
on the kernel. For example,
from kernelAccess import mdb
def onPartsChanged():
print 'The parts repository changed.'
keys = mdb.models['Model-1'].parts.keys() # OK
print 'The new keys are:', keys
if keys:
mdb.models['Model-1'].parts[keys[0]].registerQuery(onPartsChanged) # Not OK
# Internally the registerQuery method will be called on abaqusGui.mdb...
mdb.models['Model-1'].parts.registerQuery(onPartsChanged)
If a changeKey command that affects the names in the parts repository is subsequently issued,
the above example will fail. The keys (part names) are obtained using the kernelAccess mdb
proxy object and contain the changed name. However, the registerQuery method—based on the
abaqusGui proxy object—does not see the new names until the changeKey command is completed.
The registerQuery on the newly named part object (using keys()[0]) is being called within
the callback, before the changeKey command is completed, and the callback is using the new name.
Since the abaqusGui proxy for the parts repository has not yet been updated, a Keyerror is raised.
Run the above example in the GUI, create a part, then enter the following in the command line
interface (CLI):
The error can cause Abaqus/CAE to stop responding. Setting the second argument on registerQuery
to False prevents the callback from being called immediately and prevents this potential error.
6–25
Abaqus ID:
Printed on:
RECEIVING NOTIFICATION OF KERNEL DATA CHANGES
• CommandRegister allows you to create general classes. For more information, see
“CommandRegister class,” Section 5.6.3 of the Abaqus Scripting User’s Manual.
• RepositorySupport allows you to create repositories below other repositories. For more
information, see “RepositorySupport,” Section 5.6.6 of the Abaqus Scripting User’s Manual.
• RegisteredDictionary allows you to create custom dictionaries. For more information, see
“Registered dictionaries,” Section 5.6.7 of the Abaqus Scripting User’s Manual.
• RegisteredList allows you to create custom lists. For more information, see “Registered lists,”
Section 5.6.8 of the Abaqus Scripting User’s Manual.
• RegisteredTuple allows you to create custom tuples. For more information, see “Registered
tuples,” Section 5.6.9 of the Abaqus Scripting User’s Manual.
For more information on the customKernel module, see “Extending the Abaqus Scripting
Interface,” Section 5.6 of the Abaqus Scripting User’s Manual.
6–26
Abaqus ID:
Printed on:
MODE PROCESSING
7. Modes
A mode is a mechanism for gathering input from the user, processing that input, and then issuing a
command to the kernel. This section describes the modes that are available in the Abaqus GUI Toolkit.
The following topics are covered:
• “An overview of modes,” Section 7.1
• “Mode processing,” Section 7.2
• “Form modes,” Section 7.3
• “Procedure modes,” Section 7.4
• “Picking in procedure modes,” Section 7.5
Procedure Modes
Procedure modes provide an interface that uses the prompt area to guide the user through a sequence
of steps that collect input from dialog boxes or from selections in the viewport.
If a mode needs to perform drawing or highlighting in the current viewport, the mode must be a procedure
mode. Because Abaqus/CAE highlights objects that the user picks, any mode that requires the user to
pick in the viewport must also be a procedure mode. Procedure modes ensure that only one procedure
at a time has control over the scene in the current viewport. If two different procedures could highlight
different portions of the model for different purposes, the resulting display would be confusing and
ambiguous.
Modes are typically activated by a button in the GUI. Once a mode is activated, it is responsible for
gathering user input, processing the input, sending a command, and performing any error handling
associated with the mode or the commands it sends. This section describes how modes are processed.
The following topics are covered:
• “The mode processing sequence,” Section 7.2.1
• “Activating a mode,” Section 7.2.2
7–1
Abaqus ID:
Printed on:
MODE PROCESSING
def activate(self):
if getDisplayedObjectType() == PART:
AFXForm.activate(self)
else:
showAFXErrorDialog(getAFXApp().getAFXMainWindow(),
'A part must be displayed in the \
current viewport.')
If you write your own activate (or deactivate) method, you must call the base class version of that
method if no error conditions are encountered. The base class methods perform additional processing
necessary to make the mode function properly.
7–2
Abaqus ID:
Printed on:
MODE PROCESSING
activate() verifyKeywordValues()
getFirstStep/Dialog() Y
Errors?
More N
steps?
Y
Errors?
Y
verifyCurrentKeywordValues() N
getCommandString()
Y
Errors?
sendCommandString()
doCustomChecks() Y handleException()
Errors?
Y N
Errors?
doCustomTasks()
7–3
Abaqus ID:
Printed on:
MODE PROCESSING
doCustomChecks
The doCustomChecks method has an empty implementation in the base class. You can redefine
this method to perform any additional checking of keyword values, typically to perform range
checking or to check some interdependency between values. The doCustomChecks method
should return True if no errors were encountered; otherwise, it should return False so that further
command processing will be terminated. The doCustomChecks method is called by the mode
during step and dialog box processing and during command processing.
verifyKeywordValues
The verifyKeywordValues method calls the verify method for each keyword of
each command associated with the mode and posts an error dialog box if necessary. The
verifyKeywordValues method returns True if no errors were encountered; otherwise, it
returns False and terminates further command processing.
doCustomChecks
The doCustomChecks method has an empty implementation in the base class. You can redefine
this method to perform any additional checking of keyword values, typically to perform range
checking or to check some interdependency between values. The doCustomChecks method
should return True if no errors were encountered; otherwise, it should return False so that further
command processing will be terminated. The doCustomChecks method is called by the mode
during step and dialog box processing and during command processing.
The following example shows how you can use the doCustomChecks method to find an
invalid value and, in response, to post an error dialog box and put the cursor into the appropriate
widget. If the keyword is connected to a text field in the dialog, the onKeywordError method
finds the text field widget, select its contents, and places the focus on the widget.
def doCustomChecks(self):
7–4
Abaqus ID:
Printed on:
MODE PROCESSING
issueCommands
The issueCommands method is responsible for constructing the command string, issuing it to the
kernel, handling any exceptions from the command, and deactivating the mode if necessary. The
issueCommands method calls the following methods:
• getCommandString: This method returns a string that represents the commands collected
from each command associated with the mode. Required keywords are always sent with the
command, but optional keywords are sent only if their value has changed. The commands
are issued to the kernel in the same order as the commands were constructed in the mode. If
your command does not fit the standard style of the command generated by the mode, you can
redefine this method to generate your own command string.
• sendCommandString: This method takes the command string returned from the
getCommandString method and sends it to the kernel for processing. You should not
overwrite this method or your mode may not perform properly.
• doCustomTasks: This method has an empty implementation in the base class. You can
redefine this method to perform any additional tasks required after a command is processed by
the kernel.
After calling these methods, the issueCommands method will deactivate the mode if the user
pressed the OK button.
The issueCommands method also controls the writing of the command to the
replay and journal files. The GUI infrastructure always calls issueCommands with
writeToReplay=True and writeToJournal=False. If you want to change the behavior,
you can overwrite this method and specify different values for the arguments. If you overwrite the
issueCommands method you must specify both arguments, and you should always call the base
class method from your method or your mode may not perform properly. For example:
In most cases, you do not need to call issueCommands since the infrastructure will call
it automatically; however, if you interrupt the normal flow of mode processing, you must call
issueCommands to complete the processing. For example, if before issuing a command you want
to ask the user for permission to execute the command, you can post a warning dialog box from the
doCustomChecks method. In this example you must return False from the doCustomChecks
method to stop the command processing. The application will then wait for the user to make a
selection from the warning dialog box. When the user clicks a button in the warning dialog box,
you must catch the message sent by the dialog box to your form. If the user clicks Yes, you should
continue the command processing as shown in the following example:
7–5
Abaqus ID:
Printed on:
MODE PROCESSING
class MyForm(AFXForm):
ID_OVERWRITE = AFXForm.ID_LAST
AFXForm.__init__(self, owner)
FXMAPFUNC(self, SEL_COMMAND,
self.ID_OVERWRITE, MyForm.onCmdOverwrite)
...
def doCustomChecks(self):
import os
if os.path.exists(self.fileNameKw.getValue()):
db = self.getCurrentDialog()
showAFXWarningDialog(db,
'File already exists.\n\nOK to overwrite?',
AFXDialog.YES|AFXDialog.NO, self,
self.ID_OVERWRITE)
return False
return True
if sender.getPressedButtonId() == \
AFXDialog.ID_CLICKED_YES:
self.issueCommands(writeToReplay=True,
writeToJournal=True)
return 1
Normally the GUI infrastructure takes care of sending commands to the kernel automatically
when the mode is committed. If you need to issue a command before the mode is committed, you
can call issueCommands yourself. In other cases you may want to send a command without
using the form’s infrastructure. You can send a command string directly to the kernel using the
sendCommand(cmd) method. For more information, see “Executing commands,” Section 6.3.
deactivate
After the mode has issued its commands successfully, it will call the deactivate method to
perform various cleanup tasks, unless the mode loops or an “Apply” button was pressed, in which
case the mode returns to wait for further input from the user. If you need to perform your own
7–6
Abaqus ID:
Printed on:
MODE PROCESSING
cleanup tasks for your mode, you can overwrite this method; but you should be sure to call the
base class method as well to ensure that the mode is terminated properly as shown in the following
example.
def deactivate(self):
cancel
If you need to cancel a mode programmatically, as opposed to the user clicking on a Cancel button,
you can call the mode’s cancel method, taking the default values for its arguments. The cancel
method will call the deactivate method, so the mode’s cleanup tasks will still be performed.
If you want to give the user a chance to confirm whether a mode should be cancelled, you can
have a bailout dialog invoked. If you are writing a form mode, you can specify the bailout flag
in the constructor of your dialog box. If you are writing a procedure mode, you should write the
checkCancel method. The return value of the checkCancel method determines if the user
will be prompted for confirmation when the procedure is cancelled. For example:
def checkCancel(self):
if self.getCurrentStep() == self.step1:
# If cancelled in the first step, do not
# ask the user for confirmation to cancel.
return AFXProcedure.BAILOUT_OK
else:
# After the first step, ask the user for
# confirmation before cancelling.
return AFXProcedure.BAILOUT_NOTOK
By default when the context changes in Abaqus/CAE, all forms are cancelled; for example,
when the user opens a new database or changes the current model. If you have a form mode that
you do not want to be cancelled, you can overwrite the base class implementation in your form code
as follows:
def okToCancel(self):
return False
7–7
Abaqus ID:
Printed on:
MODE PROCESSING
exceptionType = exception[0]
exceptionValue = exception[1]
7–8
Abaqus ID:
Printed on:
FORM MODES
db = self.getCurrentDialog()
showAFXErrorDialog(db, str(exceptionValue))
A form mode gathers input from the user using one or more dialog boxes. This section describes the two
methods used by forms for posting dialog boxes. The following topics are covered:
• “Form example,” Section 7.3.1
• “Form constructor,” Section 7.3.2
• “getFirstDialog,” Section 7.3.3
• “getNextDialog,” Section 7.3.4
• “Collecting input from the GUI,” Section 7.3.5
class PlateForm(AFXForm):
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def __init__(self, owner):
AFXForm.__init__(self, owner)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def getFirstDialog(self):
self.cmd.setKeywordValuesToDefaults()
return PlateDB(self)
7–9
Abaqus ID:
Printed on:
FORM MODES
7.3.3 getFirstDialog
You must write the getFirstDialog method for your mode. The getFirstDialog method
should return the first dialog box of the mode. In “Form example,” Section 7.3.1, a pointer to the form
is passed into the dialog box constructor. The dialog box will use this pointer to access the mode’s
keywords.
If you want the same default values to appear every time you post the dialog box, you must call the
setKeywordValuesToDefaults() method before returning the dialog box, as shown in “Form
example,” Section 7.3.1.
7.3.4 getNextDialog
If your mode contains more than one dialog box, you must write the getNextDialog method
in addition to the getFirstDialog method. The previous dialog box is passed into the
getNextDialog method so that you can determine where the user is in the sequence of dialog boxes
and act accordingly. The getNextDialog method should return the next dialog box in the sequence,
or it should return None to indicate that it has finished collecting input from the user. The following
7–10
Abaqus ID:
Printed on:
FORM MODES
example is a modified version of the example in “getFirstDialog,” Section 7.3.3, that illustrates how
inputs are collected from the user in a series of three dialog boxes rather than just one:
def getFirstDialog(self):
self.dialog1 = PlateDB1(self)
return self.dialog1
if previousDb == self.dialog1:
self.dialog2 = PlateDB2(self)
return self.dialog2
elif previousDb == self.dialog2:
self.dialog3 = PlateDB3(self)
return self.dialog3
else:
return None
class PlateDB(AFXDataDialog):
va = AFXVerticalAligner(self)
AFXTextField(va, 15, 'Name:', mode.nameKw, 0)
AFXTextField(va, 15, 'Width:', mode.widthKw, 0)
AFXTextField(va, 15, 'Height:', mode.heightKw, 0)
7–11
Abaqus ID:
Printed on:
PROCEDURE MODES
class PlateProcedure(AFXProcedure):
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def __init__(self, owner):
AFXProcedure.__init__(self, owner)
7–12
Abaqus ID:
Printed on:
PROCEDURE MODES
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def getFirstStep(self):
self.cmd.setKeywordValuesToDefaults()
db = PlateDB(self)
return AFXDialogStep(self, db)
7–13
Abaqus ID:
Printed on:
PROCEDURE MODES
7.4.3 getFirstStep
You must always write the getFirstStep method for your mode. The getFirstStep method
should return the first step of the mode. In “Procedure example,” Section 7.4.1, a pointer to the procedure
is passed into the dialog box constructor. The dialog box will use this pointer to access the mode’s
keywords.
If you want the same default values to appear every time you post the dialog box, you must call
the setKeywordValuesToDefaults() method before returning the dialog box, as shown in
“Procedure example,” Section 7.4.1.
7.4.4 getNextStep
If your mode contains more than one step, you must write the getNextStep method in addition to the
getFirstStep method. The previous step is passed into the getNextStep method so that you can
determine where the user is in the sequence of steps and act accordingly. The getNextStep method
should return the next step in the sequence, or it should return None to indicate that it has finished
collecting input from the user. The following example, which is a modified version of the example in
“Procedure example,” Section 7.4.1, illustrates how inputs are collected from the user in a series of three
steps rather than just one:
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def getFirstStep(self):
self.cmd.setKeywordValuesToDefaults()
self.plateWidthDB = None
self.plateHeightDB = None
db = PlateNameDB(self)
self.step1 = AFXDialogStep(self, db)
return self.step1
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def getNextStep(self, previousStep):
if previousStep == self.step1:
if not self.plateWidthDB:
self.plateWidthDB = PlateWidthDB(self)
self.step2 = AFXDialogStep(self, self.plateWidthDB)
return self.step2
7–14
Abaqus ID:
Printed on:
PROCEDURE MODES
if not self.plateHeightDB:
self.plateHeightDB = PlateHeightDB(self)
self.step3 = AFXDialogStep(self, self.plateHeightDB)
return self.step3
else:
return None
7.4.5 getLoopStep
If you want your procedure to loop, you must write the getLoopStep method. The getLoopStep
method is defined in the base class to return None, indicating that the mode will be run through a single
time. You can redefine the getLoopStep method and return a step to which the procedure should loop
back. The following example shows how you can make the procedure shown in the previous section
loop back to the first step after it has completed the last step:
def getLoopStep(self):
return self.step1
7.4.6 AFXDialogStep
The AFXDialogStep class allows you to post a dialog box during a procedure. To create a dialog
step, you must supply the procedure, a dialog box, and, optionally, a prompt for the prompt line. If you
do not supply a prompt, Abaqus uses a default prompt of Fill out the dialog box title
dialog. The following is an example of a dialog step in a single step procedure:
def getFirstStep(self):
db = PlateDB(self)
prompt = 'Enter plate dimensions in the dialog box'
return AFXDialogStep(self, db, prompt)
In most cases a procedure will have more than one step. Since a procedure has the ability to back up
to previous steps, you must write procedures that do not construct dialog boxes more than once during the
procedure. You can prevent a procedure from constructing dialog boxes more than once by initializing
procedure members and then checking the members during getNextStep, as shown in the following
example:
def getFirstStep(self):
self.plateWidthDB = None
self.plateHeightDB = None
db = PlateNameDB(self)
7–15
Abaqus ID:
Printed on:
PICKING IN PROCEDURE MODES
if previousStep == self.step1:
if not self.plateWidthDB:
self.plateWidthDB = PlateWidthDB(self)
self.step2 = AFXDialogStep(self, self.plateWidthDB)
return self.step2
else:
return None
This section describes picking in procedure modes. The following topics are covered:
• “AFXPickStep,” Section 7.5.1
• “Refining what the user can select,” Section 7.5.2
• “Nonpickable entities,” Section 7.5.3
• “Highlighting while selecting,” Section 7.5.4
• “Selection options,” Section 7.5.5
• “Allowing the user to type in points,” Section 7.5.6
• “Picking by angle,” Section 7.5.7
• “AFXOrderedPickStep,” Section 7.5.8
• “Limitations while selecting,” Section 7.5.10
7.5.1 AFXPickStep
The AFXPickStep class allows the user to pick entities in the current viewport. You must create the
keywords associated with pick steps in the same order as the pick steps in which the keywords are used.
7–16
Abaqus ID:
Printed on:
PICKING IN PROCEDURE MODES
For example, if you have two pick steps, you must create the keyword passed into the first pick step
before you create the second keyword, which is passed into the second pick step. Creating the keywords
associated with pick steps in the same order as the pick steps in which the keywords are used ensures
that the necessary setup commands are issued in the proper order for the command to work correctly.
You can specify many parameters when picking items from the viewport. You specify some of
these parameters in the AFXPickStep constructor, and you specify other parameters by calling various
methods of the pick step.
To construct a pick step, you must at least supply the following:
• A procedure
• An object keyword
• A prompt for the prompt line
• A bit flag or flags specifying which type of entities may be picked
The following example shows how you can write a pick step:
class MyProcedure(AFXProcedure):
AFXProcedure.__init__(self, owner)
def getFirstStep(self):
7–17
Abaqus ID:
Printed on:
PICKING IN PROCEDURE MODES
The sequence style controls how a sequence of picked objects is represented in the command
string. If the sequence style is AFXPickStep.ARRAY, the picked objects will be represented as
the concatenation of slices of arrays; for example, v[3:4] + v[5:8], where v is a vertex array. You
cannot use the AFXPickStep.ARRAY sequence style to pick a combination of entities with multiple
types because only objects of the same type can be concatenated. In addition, you cannot use
the AFXPickStep.ARRAY sequence style to pick interesting points because interesting points are
constructed on-the-fly and are not accessible from slices of an array.
If the sequence style is AFXPickStep.TUPLE, the picked objects will be represented as a tuple of
individual objects; for example, ( v[3], v[5], v[6], v[7]). The style you choose depends on the format
accepted by the command that you intend to issue. Some commands in Abaqus/CAE accept both styles,
but some accept only one or the other. For further details on the arguments to the AFXPickStep
constructor, see the Abaqus GUI Toolkit Reference Manual.
By default, no refinements are set. For a complete list of refinements, see the Abaqus GUI Toolkit
Reference Manual.
Disallowing repeated picks works only for geometry items such as vertices, edges, and faces; it does not
work for nodes and elements.
7–18
Abaqus ID:
Printed on:
PICKING IN PROCEDURE MODES
7–19
Abaqus ID:
Printed on:
PICKING IN PROCEDURE MODES
text field and the user selects an entity in the viewport, that entity will be used in the command, regardless
of whether anything was typed in the text field. The mode automatically takes care of deactivating
whichever keyword needs to be deactivated based on these rules. In the previous example, if the user
types in a point, self.pointKw1 will be deactivated and self.pointKw2 will be activated. In addition,
self.pointKw2 will contain the value entered by the user.
7.5.8 AFXOrderedPickStep
The AFXOrderedPickStep is a special pick step that preserves the order in which the user picks entities.
For example, when picking four nodes to create a quad element, the order in which the user picks the
nodes is important and must be preserved during picking. The user must pick the entities one at a time
and cannot drag select them. In addition, because this is a single step that treats the picked entities as a
single pick, the user cannot backup any of the individual picks. The step continues to loop until the user
clicks the mouse button two.
There are similar methods for adding entities from geometry sets (addGeometrySetSelection),
element sets (addElementSetSelection), and surfaces (addSurfaceSelection). When this
step is executed the added entities will automatically be highlighted, and the user can add or remove
from that selection.
7–20
Abaqus ID:
Printed on:
PICKING IN PROCEDURE MODES
7–21
Abaqus ID:
Printed on:
Part V: GUI modules and toolsets
This part describes how you can create your own modules and toolsets. This part also describes how you can
modify an existing Abaqus/CAE module or toolset. The following topics are covered:
• Chapter 8, “Creating a GUI module”
• Chapter 9, “Creating a GUI toolset”
• Chapter 10, “Customizing an existing module or toolset”
Abaqus ID:
Printed on:
GUI MODULE EXAMPLE
8–1
Abaqus ID:
Printed on:
GUI MODULE EXAMPLE
toolbox icons. As a result, the menus, toolbars, and icons can be swapped in and out automatically as
the user changes modules.
The following example shows how to create a module GUI; subsequent sections explain the details
of this example.
# Menu items
#
menu = AFXMenuPane(self)
AFXMenuTitle(self, '&Menu1', None, menu)
AFXMenuCommand(self, menu, '&Item 1', None, mode_1,
AFXMode.ID_ACTIVATE)
subMenu = AFXMenuPane(self)
AFXMenuCascade(self, menu, '&Submenu', None, subMenu)
AFXMenuCommand(self, subMenu, '&Subitem 1', None, mode_2,
AFXMode.ID_ACTIVATE)
# Toolbar items
#
group = AFXToolbarGroup(self)
icon = FXXpmIcon(getAFXApp(), iconData1)
AFXToolButton(group, '\tTool Tip', icon, mode_1,
AFXMode.ID_ACTIVATE)
8–2
Abaqus ID:
Printed on:
GUI MODULE EXAMPLE
# Toolbox items
#
group = AFXToolboxGroup(self)
icon = FXXPMIcon(getAFXApp(), iconData2)
AFXToolButton(group, '\tTool Tip’, icon, mode_1,
AFXMode.ID_ACTIVATE)
popup = FXPopup(getAFXApp().getAFXMainWindow())
AFXFlyoutItem(popup, '\tFlyout Button1', squareIcon,
mode_1, AFXMode.ID_ACTIVATE)
AFXFlyoutItem(popup, '\tFlyout Button 2', circleIcon,
mode_2, AFXMode.ID_ACTIVATE)
AFXFlyoutItem(popup, '\tFlyout Button 3', triangleIcon,
mode_3, AFXMode.ID_ACTIVATE)
AFXFlyoutButton(group, popup)
# Register toolsets
#
self.registerToolset(MyToolsetGui(),
GUI_IN_MENUBAR|GUI_IN_TOOL_PANE)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def getKernelInitializationCommand(self):
return 'import myModule'
8–3
Abaqus ID:
Printed on:
GUI MODULE EXAMPLE
AFXModuleGui.ASSEMBLY, your module must import the assembly kernel module because the
assembly kernel module is required to initialize some assembly display options. For more information,
see “Kernel module initialization,” Section 8.2.7.
8–4
Abaqus ID:
Printed on:
GUI MODULE EXAMPLE
8–5
Abaqus ID:
Printed on:
REGISTERING A GUI MODULE
The example in “GUI module example,” Section 8.2, registers a toolset that contains elements in the
main menu bar and the Tools menu.
If you do not specify a flag in an area in which you have created some GUI components, those
components will not be shown in the application.
8–6
Abaqus ID:
Printed on:
SWITCHING TO A GUI MODULE
switchModule('My Module')
def onModuleSwitch(moduleName):
if moduleName == 'Part':
# Do part module tasks
elif moduleName == 'Mesh':
# Do mesh module tasks
etc.
setSwitchModuleHook(onModuleSwitch)
8–7
Abaqus ID:
Printed on:
GUI TOOLSET EXAMPLE
class MyToolsetGui(AFXToolsetGui):
9–1
Abaqus ID:
Printed on:
REGISTERING TOOLSETS
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def __init__(self):
In the constructor of the new class you call the constructor of the base class. The AFXToolsetGui
class takes the following argument:
toolsetName
A String specifying the name of the toolset. The toolset name provides an identifier for the toolset.
9–2
Abaqus ID:
Printed on:
MODIFYING AND ACCESSING Abaqus/CAE GUI MODULES AND TOOLSETS
Deriving a new class to create modified Abaqus/CAE modules and toolsets allows you to customize
existing functions without changing the original functions. You can also access existing Abaqus/CAE
functions from within new dialogs that you create with the Abaqus GUI Toolkit. The following topics
are covered in this section:
• “Abaqus/CAE GUI modules and toolsets,” Section 10.1.1
• “Accessing Abaqus/CAE functions,” Section 10.1.2
10–1
Abaqus ID:
Printed on:
MODIFYING AND ACCESSING Abaqus/CAE GUI MODULES AND TOOLSETS
When you register a module derived from one of the Abaqus/CAE modules, you must use the name
shown in the table for the displayedName argument in the main window’s registerModule method.
If you do not use the name shown, some GUI infrastructure components may not function correctly.
InteractionGui “Interaction”
LoadGui “Load”
MeshGui “Mesh”
OptimizationGui “Optimization”
JobGui “Job”
VisualizationGui “Visualization”
SketchGui ”Sketch”
When you register a toolset, you must specify in the registerToolset method in which
locations (the menu bar, the toolbar, or the toolbox) the toolset creates the widget. If you omit a toolset
location flag, the GUI for that toolset will not appear in that location. The table below shows the class
name for each of the Abaqus/CAE toolsets along with the flags that indicate the locations in which the
toolset creates the widgets. You can import these class names from abaqusGui.
To register the plug-in toolset, you call registerPluginToolset(); you do not use the
registerToolset method.
When you unregister a toolset, you must use the name shown in the table as the argument to the
module’s unregisterToolset method.
10–2
Abaqus ID:
Printed on:
MODIFYING AND ACCESSING Abaqus/CAE GUI MODULES AND TOOLSETS
For an example of how to register the toolsets and modules used by Abaqus/CAE, see “Main window
example,” Section 14.2.1. The following statements show how you could add your own toolset to the
Visualization module:
# File myVisModuleGui.py:
class MyVisModuleGui(VisualizationGui):
def __init__(self):
# Register my toolset.
10–3
Abaqus ID:
Printed on:
MODIFYING AND ACCESSING Abaqus/CAE GUI MODULES AND TOOLSETS
#
self.registerToolset(MyToolsetGui(),
GUI_IN_MENUBAR|GUI_IN_TOOLBOX)
MyVisModuleGui()
# File myMainWindow.py:
class MyMainWindow(AFXMainWindow):
...
self.registerModule('Visualization',
'myVisModuleGui')
...
If you derive a toolset from an Abaqus/CAE toolset, you must construct that toolset using the
makeCustomToolsets method of AFXMainWindow. You must use the makeCustomToolsets
method to ensure that the toolset is created at the appropriate time during application startup. This
will avoid any conflicts with Abaqus/CAE modules that also make use of the module. For
example, if you derive a new toolset from the Datum toolset, you must create the new toolset in
makeCustomToolsets. This approach is illustrated in the following example. The new toolset will
also appear in the Part module in place of the standard Datum toolset.
class MyMainWindow(AFXMainWindow):
...
def makeCustomToolsets(self):
10–4
Abaqus ID:
Printed on:
THE FILE TOOLSET
class MyModuleGui(AFXModuleGui):
def __init__(self):
...
mw = getAFXApp().getAFXMainWindow()
self.registerToolset(mw.myDtmGui,
GUI_IN_TOOL_PANE|GUI_IN_TOOLBOX)
class MyFileToolsetGui(FileToolsetGui):
10–5
Abaqus ID:
Printed on:
THE TREE TOOLSET
def switchToMdbModule(self):
def switchToOdbModule(self):
def makeTabs(self):
self.makeModelTab()
self.makeMyTab()
10–6
Abaqus ID:
Printed on:
THE SELECTION TOOLSET
self.makeMaterialLibraryTab()
self.makeResultsTab()
def makeMyTab(self):
vf = getAFXApp().getAFXMainWindow().appendTreeTab(
'My Tab', 'My Tab')
FXLabel(vf, 'This is my tab item')
The first argument to the appendTreeTab method is the text that you want to show up in the tab
button. The second argument is the name of the tab, which is used for identification purposes in various
application programming interfaces, such as setCurrentTreeTab(name).
By default, when you create a tab it will be visible in all modules, and it will be applicable to
all modules. If you do not want your tab to be visible or applicable to all modules, you can use the
setApplicabilityForTreeTab and setVisibilityForTreeTab methods. When the user
switches to a new module, the application will check to see if the current tab is visible in and applicable
to the new module. If the tab is not visible, it will be hidden. If it is not applicable, the application will
search for the first tab that is applicable to the new module and make that tab current. For example:
def makeMyTab(self):
vf = getAFXApp().getAFXMainWindow().appendTreeTab(
'My Tab', 'My Tab')
getAFXApp().getAFXMainWindow().setApplicabilityForTreeTab(
'My Tab', 'Part, Property')
getAFXApp().getAFXMainWindow().setVisibilityForTreeTab(
'My Tab', 'Part, Property')
In this case, when the user is in the Part module, My Tab will be shown. If the user clicks on My Tab
to make it current and then switches to the Property module, My Tab will remain visible and current.
If the user switches to the Step module, My Tab will be hidden and the Model tab will become current
(because it has been defined as applicable to all modules except the Visualization module).
10–7
Abaqus ID:
Printed on:
THE HELP TOOLSET
You can use the getToolset method of the main window to get the selection toolset, and then use the
setFilterTypes method of the selection toolset.
• setFilterTypes(types, defaultType)
Use the following flags for the types and defaultType arguments:
• SELECTION_FILTER_NONE
• SELECTION_FILTER_ALL
• SELECTION_FILTER_VERTEX
• SELECTION_FILTER_EDGE
• SELECTION_FILTER_FACE
• SELECTION_FILTER_CELL
• SELECTION_FILTER_DATUM
• SELECTION_FILTER_REF_POINT
• SELECTION_FILTER_NODE
• SELECTION_FILTER_ELEMENT
• SELECTION_FILTER_FEATURE
For example:
class MyModuleGui(AFXModuleGui):
...
def activate(self):
toolset = getAFXApp().getAFXMainWindow().getToolset(
'Selection')
toolset.setFilterTypes(
SELECTION_FILTER_CELL|SELECTION_FILTER_FACE,
SELECTION_FILTER_FACE)
AFXModuleGui.activate(self)
10–8
Abaqus ID:
Printed on:
THE HELP TOOLSET
• setCustomLogoIcon(logoIcon)
For example:
class MyMainWindow(AFXMainWindow):
...
An alternative way to provide help in your application is to use special methods that allow you to
post a URL in a web browser. For example:
You can use any valid URL syntax, such as “http” or “file.” displayURL will display the URL in a
currently open browser window (if there are none, it will open a new window). openWithURL will
10–9
Abaqus ID:
Printed on:
AN EXAMPLE OF CUSTOMIZING A TOOLSET
always open a new browser window. No exceptions are thrown, but you can check the return status of
these methods for success.
class MyFileToolsetGui(FileToolsetGui):
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def __init__(self):
10–10
Abaqus ID:
Printed on:
AN EXAMPLE OF CUSTOMIZING A TOOLSET
Figure 10–1 The toolbar and the File menu before and after executing the example script.
getWidgetFromText(menu, 'New').hide()
getWidgetFromText(menu, 'Save').hide()
getWidgetFromText(menu, 'Save As...').hide()
getSeparator(menu, 2).hide()
10–11
Abaqus ID:
Printed on:
AN EXAMPLE OF CUSTOMIZING A TOOLSET
10–12
Abaqus ID:
Printed on:
Part VI: Creating a customized application
This part describes how you create a customized application. The following topics are covered:
• Chapter 11, “Creating an application”
• Chapter 12, “The application object”
• Chapter 13, “The main window”
• Chapter 14, “Customizing the main window”
Abaqus ID:
Printed on:
STARTUP SCRIPT
11–1
Abaqus ID:
Printed on:
STARTUP SCRIPT
GUI Modules, Toolsets Functionality grouped by task (e. g., Part module, Datum toolset)
• Instantiates a main window. The main window is what the user sees when the application is first
started and provides access to all of the application’s functionality.
• Creates and runs the application. Once the application is run, it enters an event loop where it waits
to react to user input, such as the click of a mouse.
The following illustrates a typical startup script.
from abaqusGui import *
import sys
from caeMainWindow import CaeMainWindow
11–2
Abaqus ID:
Printed on:
STARTUP SCRIPT
The first statement in the script imports all constructors, including the AFXApp constructor, from the
abaqusGui module, which contains access to the entire Abaqus GUI Toolkit. The sys module is
also imported since it is needed to pass arguments into the application’s init method. After the script
imports the sys module, it imports the main window constructor.
This startup script has been customized to include a startup callback function that will display
a custom dialog, MyStartupDB, after the application starts. The callback is defined after the import
statements and before the application is initialized. The next statements instantiate and initialize the
application object. The application object is discussed in more detail in “The application object,”
Section 12.1. The script then instantiates the main window. The main window is what the user will see
when the application is started. The main window is discussed in more detail in Chapter 13, “The main
window.”
The application constructor creates all the data structures needed for that object, and the
app.create() statement creates all the GUI windows required by the application object. Next, the
custom callback startup function is registered.
The app.run() statement displays the application, including the custom startup dialog, and then
enters an event loop. The event loop then waits for user interaction.
When you start your custom application, you may want to use the –noStartup option in the
Abaqus/CAE execution procedure to prevent Abaqus/CAE from posting its own startup dialog. For
more information, see “Abaqus/CAE execution,” Section 3.2.5 of the Abaqus Analysis User’s Manual.
11–3
Abaqus ID:
Printed on:
INSTALLATION
11.4 Installation
You can use a simpler syntax to start an application that has been installed at a site. Installing an
application involves the following steps:
• Add an entry to the abaqus_dir/SMA/site/abaqus.app file, where abaqus_dir is the name of
the directory in which Abaqus is installed. To determine the location of abaqus_dir at your site,
type abaqus whereami at the operating system prompt.
The format of entries in the abaqus.app file is
applicationName cae | viewer -custom startupScript
where applicationName is the name that the user must specify on the command line to start the
application.
– The second parameter determines the type of token that the application will check out—cae
or viewer.
– startupScript is the name of the startup script without any file extension. The script must
reside in a directory specified in the PYTHONPATH environment variable. applicationName
and startupScript can be the same.
• Edit the abaqus_dir/SMA/site/abaqus.aev file. You must add the directory that contains the
customization script to the definition of the PYTHONPATH environment variable. By convention,
customization scripts are located in directories underneath abaqus_dir/customApps. You should
11–4
Abaqus ID:
Printed on:
INSTALLATION
add your directory near to the end of the PYTHONPATH definition, just prior to the current directory
(.). This will ensure that you do not override any existing settings in the PYTHONPATH definition.
To keep the path to your application portable and generic, you should use an environment
variable to specify the root of the path. For a standard Abaqus installation, the $ABA_HOME
environment variable refers to the same directory as abaqus_dir. As a result, you can use the
$ABA_HOME environment variable to specify the directory that contains your customization script;
for example,
$ABA_HOME/customApps/myApp
For example, to include the myApp directory shown above in the PYTHONPATH, you should
change the PYTHONPATH definition in abaqus.aev from this
PYTHONPATH
$ABA_HOME/cae/Python/Lib:$ABA_HOME/cae/Python/Obj:
$ABA_HOME/cae/exec/lbr:.:$PYTHONPATH
to this
PYTHONPATH
$ABA_HOME/cae/Python/Lib:$ABA_HOME/cae/Python/Obj:
$ABA_HOME/cae/exec/lbr:$ABA_HOME/customApps/myApp:
.:$PYTHONPATH
• There are syntax differences between UNIX systems and Windows systems. By default, Abaqus
uses UNIX syntax and automatically converts the UNIX syntax to Windows syntax if the application
is run on a Windows platform. However, if you need to specify the drive letter of your path on a
Windows system, you must use Windows syntax. To use Windows syntax, you must make the
following changes to the entire PYTHONPATH line:
UNIX Windows
: ;
/ \
$NAME %NAME%
The following example shows an abaqus.aev file that refers to a drive letter and has been
modified to run on a Windows system:
ABA_PATH $ABA_HOME:$ABA_HOME/cae
PYTHONPATH
%ABA_HOME%\cae\Python\Lib;%ABA_HOME%\cae\Python\Obj;
11–5
Abaqus ID:
Printed on:
INSTALLATION
%ABA_HOME%\cae\exec\lbr;d:\boltApp1;.;%PYTHONPATH%
ABA_LIBRARY_PATH
$ABA_HOME/cae/ABA_SELECT:
$ABA_HOME/cae/exec/lbr:$ABA_HOME/cae/Python/Obj/lbr:
$ABA_HOME/cae/External/Acis:$ABA_HOME/cae/External:
$ABA_HOME/cae/External/ebt:$ABA_HOME/exec
abaqus applicationName
11–6
Abaqus ID:
Printed on:
COMMON METHODS
The application and vendor names are intended to be keys into the registry. The registry is a place to
store settings that are persistent between sessions of the application; for example, the size and location of
the application on the desktop when the application it starts. The registry is currently not used by Abaqus,
but these keys are included as placeholders for future capabilities. The registry will have various sections
that allow you to group settings. Some settings may apply to all products from a particular vendor, and
some settings may apply to only a specific product from a vendor.
By default, Abaqus displays the product name and release numbers in the main window’s title bar;
for more information, see “The title bar,” Section 13.2.
app = getAFXApp()
The following list shows some of the most commonly used application methods:
getAFXMainWindow()
Returns a handle to the main window object.
getProductName()
Returns the product name.
12–1
Abaqus ID:
Printed on:
COMMON METHODS
getVersionNumbers()
Returns a tuple of (majorNumber, minorNumber, updateNumber).
getPrerelease()
Returns True if this application is a prerelease.
beep()
Rings the system bell.
12–2
Abaqus ID:
Printed on:
AN OVERVIEW OF THE MAIN WINDOW
title
A String that will be shown in the title bar of the main window.
13–1
Abaqus ID:
Printed on:
THE TITLE BAR
icon
A 32 × 32 pixel icon used for the application on the desktop.
miniIcon
A 16 × 16 pixel used on Windows for the application in the title bar and system tray.
opts
Flags controlling various window behavior.
x,y,w,h
The X-, Y-location of the window, and the width and height of the window. The default value of
zero indicates that the system should calculate these numbers automatically. The main window
size and location are stored in abaqus_v6.12.gpr when the application exits so that when the
application is started again it will appear in the same location with the same size. Therefore, it is
recommended that you do not set x, y, w, or h in the main window constructor; however, if you do,
those settings will override the settings in abaqus_v6.12.gpr.
The following statement shows how you can access the main window:
mainWindow = getAFXApp().getAFXMainWindow()
The layout of the main window is shown in Figure 13–1.
13–2
Abaqus ID:
Printed on:
THE TITLE BAR
Model
Tree
Module
Toolbox
Prompt area
Message area
Command
line interface
If you do not specify the major, minor, and update numbers in the application constructor, they
default to the current Abaqus/CAE release numbers. Similarly, if you specify release numbers but you
do not specify a product name, the release numbers default to the current Abaqus/CAE release numbers.
If you set the prerelease argument in the AFXApp constructor to True, the update number is preceded by
PRE. For example, Abaqus/CAE 6.12-PRE1.
In addition, if the user has opened a model database, the title bar string contains
the name of the current model database; for example, Abaqus/CAE 6.12–1 MDB:
C:\projects\cars\engines\turbo-1.cae.
If the name of the current model database, including the path, exceeds 50 characters, the name will
be abbreviated by showing only the first and last 25 characters separated by “…”.
If you do not want the default title processing, you can override it by specifying a title in the
AFXMainWindow constructor. If you specify a title in the AFXMainWindow constructor, the
Abaqus GUI Toolkit ignores the arguments in the application constructor and uses the title specified.
The model database name and the name of the current viewport (when maximized) will continue to be
shown in the title bar, even if you override the default title processing.
You can access the string shown in the window title bar using the following statement:
title = getAFXApp().getAFXMainWindow().getTitle()
13–3
Abaqus ID:
Printed on:
TOOLBARS
13.4 Toolbars
By default, Abaqus/CAE displays all of the toolbars in a row underneath the main menu bar, as shown
in Figure 13–2:
Toolbar grip
You can use the following statement to access a toolbar group from the module or toolset that defines
the toolbar group:
toolbar = self.getToolbarGroup(toolbarName)
13–4
Abaqus ID:
Printed on:
THE PROMPT AREA
where self is the module or toolset, and toolbarName is the name given to the toolbar when Abaqus/CAE
constructs it. You can determine the names of the toolbars by selecting Tools→Customize from the
main menu bar and viewing the dialog box that appears.
contextBar = getAFXApp().getAFXMainWindow().getContextBar()
toolbox = getAFXApp().getAFXMainWindow().getToolbox()
canvas = getAFXApp().getAFXMainWindow().i_getCanvas()
The “i_” in the method name indicates that this is an internal method that you should not normally use—it
is expected that only the GUI infrastructure needs to access this method.
13–5
Abaqus ID:
Printed on:
THE COMMAND LINE INTERFACE
mainWindow = getAFXApp().getAFXMainWindow()
mainWindow.writeToMessageArea('Warning: Some items failed!')
The Abaqus GUI Toolkit does not expect users to use the CLI to issue Abaqus Scripting Interface
commands. Normally all commands sent from the GUI process are sent by the GUI via modes. For
more information, see Chapter 7, “Modes.” You can hide the CLI if it is not used by your application, as
shown in the following statements:
mainWindow = getAFXApp().getAFXMainWindow()
mainWindow.hideCli()
13–6
Abaqus ID:
Printed on:
THE Abaqus/CAE MAIN WINDOW
14–1
Abaqus ID:
Printed on:
THE Abaqus/CAE MAIN WINDOW
# Register modules.
#
self.registerModule('Part', 'Part')
14–2
Abaqus ID:
Printed on:
THE Abaqus/CAE MAIN WINDOW
self.registerModule('Property', 'Property')
self.registerModule('Assembly', 'Assembly')
self.registerModule('Step', 'Step')
self.registerModule('Interaction', 'Interaction')
self.registerModule('Load', 'Load')
self.registerModule('Mesh', 'Mesh')
self.registerModule('Job', 'Job')
self.registerModule('Visualization', 'Visualization')
self.registerModule('Sketch', 'Sketch')
14–3
Abaqus ID:
Printed on:
THE Abaqus/CAE MAIN WINDOW
To register a module, you call the registerModule method. The registerModule method
takes the following arguments:
displayedName
A string that the application will display in the Module combo box in the context bar.
moduleImportName
A string that specifies the name of the module to be imported. It is your responsibility to ensure
that this name is the same as your GUI module file name (without the .py extension). For more
information, see “Instantiating the GUI module,” Section 8.2.8.
kernelInitializationCommand
A string that specifies the name of the Python command sent to the kernel when the module is
loaded.
14–4
Abaqus ID:
Printed on:
APPENDIX A: ICONS
Appendix A: Icons
The Abaqus GUI Toolkit supports the following formats for creating icons:
• XPM
• BMP
• GIF
• PNG
You can use most image editing programs to produce icon images in one of the supported formats. After
you have created the image file, you construct the icon by calling the appropriate method, as shown in the
following example:
icon = afxCreatePNGIcon('myIcon.png')
FXLabel(self, 'A label with an icon', icon)
In some cases you may need to call the icon’s create method before using it in a widget. In the previous
example, it is not necessary to call the icon’s create method because the label widget creates the icon when
the label is created. However, if you construct an icon after you call the widget’s create method, you
must call the icon’s create method before you use the icon in the widget. For more information, see “The
create method,” Section 3.8.
The format of an XPM icon is simple; and you can use any pixmap editor, or even a text editor, to create
the icon data. For more details on the XPM format, visit the XPM web site. The following image editing
programs support the XPM format:
• ImageMagick (www.imagemagick.org)
• The GIMP (www.gimp.org)
You can also find references to pixmap editors in the FAQ page on the XPM web site.
As an alternative to using the afxCreateXPMIcon method, you can define the XPM image data as a
Python list of strings and create an icon using the FXXPMIcon method, as shown in the following example.
Note: For a list of valid color names and their corresponding RGB values, see Appendix B, “Colors and
RGB values. To define a transparent color, you must define it as “c None s None”, not just “c None”.
blueIconData = [
"12 12 2 1",
". c None s None",
" c blue",
" ",
" ",
" ",
" ",
" .... ",
" .... ",
A–1
Abaqus ID:
Printed on:
APPENDIX A: ICONS
A–2
Abaqus ID:
Printed on:
APPENDIX B: COLORS AND RGB VALUES
B–1
Abaqus ID:
Printed on:
APPENDIX B: COLORS AND RGB VALUES
B–2
Abaqus ID:
Printed on:
APPENDIX B: COLORS AND RGB VALUES
B–3
Abaqus ID:
Printed on:
APPENDIX B: COLORS AND RGB VALUES
B–4
Abaqus ID:
Printed on:
APPENDIX B: COLORS AND RGB VALUES
B–5
Abaqus ID:
Printed on:
APPENDIX B: COLORS AND RGB VALUES
B–6
Abaqus ID:
Printed on:
APPENDIX B: COLORS AND RGB VALUES
B–7
Abaqus ID:
Printed on:
APPENDIX B: COLORS AND RGB VALUES
B–8
Abaqus ID:
Printed on:
APPENDIX B: COLORS AND RGB VALUES
B–9
Abaqus ID:
Printed on:
APPENDIX B: COLORS AND RGB VALUES
B–10
Abaqus ID:
Printed on:
APPENDIX B: COLORS AND RGB VALUES
B–11
Abaqus ID:
Printed on:
APPENDIX B: COLORS AND RGB VALUES
B–12
Abaqus ID:
Printed on:
APPENDIX B: COLORS AND RGB VALUES
B–13
Abaqus ID:
Printed on:
APPENDIX B: COLORS AND RGB VALUES
B–14
Abaqus ID:
Printed on:
APPENDIX B: COLORS AND RGB VALUES
B–15
Abaqus ID:
Printed on:
APPENDIX B: COLORS AND RGB VALUES
B–16
Abaqus ID:
Printed on:
APPENDIX B: COLORS AND RGB VALUES
B–17
Abaqus ID:
Printed on:
APPENDIX B: COLORS AND RGB VALUES
B–18
Abaqus ID:
Printed on:
APPENDIX B: COLORS AND RGB VALUES
B–19
Abaqus ID:
Printed on:
APPENDIX B: COLORS AND RGB VALUES
B–20
Abaqus ID:
Printed on:
APPENDIX B: COLORS AND RGB VALUES
B–21
Abaqus ID:
Printed on:
APPENDIX B: COLORS AND RGB VALUES
B–22
Abaqus ID:
Printed on:
APPENDIX B: COLORS AND RGB VALUES
B–23
Abaqus ID:
Printed on:
APPENDIX B: COLORS AND RGB VALUES
B–24
Abaqus ID:
Printed on:
APPENDIX C: LAYOUT HINTS
C–1
Abaqus ID:
Printed on:
APPENDIX C: LAYOUT HINTS
C–2
Abaqus ID:
Printed on:
APPENDIX C: LAYOUT HINTS
C–3
Abaqus ID:
Printed on:
Abaqus, the 3DS logo, SIMULIA, CATIA, SolidWorks, DELMIA, ENOVIA, 3DVIA, and Unified FEA are trademarks or registered trademarks of Dassault Systèmes or its
subsidiaries in the US and/or other countries. Other company, product, and service names may be trademarks or service marks of their respective owners. © Dassault Systèmes, 2012
About SIMULIA
SIMULIA is the Dassault Systèmes brand that delivers a scalable portfolio of
Realistic Simulation solutions including the Abaqus product suite for Unified Finite
Element Analysis; multiphysics solutions for insight into challenging engineering
problems; and lifecycle management solutions for managing simulation data,
processes, and intellectual property. By building on established technology,
respected quality, and superior customer service, SIMULIA makes realistic
simulation an integral business practice that improves product performance,
reduces physical prototypes, and drives innovation. Headquartered in Providence,
RI, USA, with R&D centers in Providence and in Vélizy, France, SIMULIA provides
sales, services, and support through a global network of regional offices and
distributors. For more information, visit www.simulia.com.
www.3ds.com