This section describes how you can create an application by deriving a new class from the AFXMainWindow class and registering the modules and toolsets used by your application. The following topics are covered:
To create a main window for a particular application, you start by deriving a new class from the AFXMainWindow class. In the constructor of the main window, you register the modules and toolsets used by your application.
The following script constructs the Abaqus/CAE main window. The script is described in detail in the following sections. Details of how you construct modules and toolsets are given in Chapter 8, “Creating a GUI module,” and Chapter 9, “Creating a GUI toolset.”
from abaqusGui import * class CaeMainWindow(AFXMainWindow): def __init__(self, app, windowTitle=''): # Construct the GUI infrastructure. # AFXMainWindow.__init__(self, app, windowTitle) # Register the "persistent" toolsets. # self.registerToolset(FileToolsetGui(), GUI_IN_MENUBAR|GUI_IN_TOOLBAR) self.registerToolset(ModelToolsetGui(), GUI_IN_MENUBAR) self.registerToolset(CanvasToolsetGui(), GUI_IN_MENUBAR) self.registerToolset(ViewManipToolsetGui(), GUI_IN_MENUBAR|GUI_IN_TOOLBAR) self.registerToolset(TreeToolsetGui(), GUI_IN_MENUBAR) self.registerToolset(AnnotationToolsetGui(), GUI_IN_MENUBAR|GUI_IN_TOOLBAR) self.registerToolset(CustomizeToolsetGui(), GUI_IN_TOOL_PANE) self.registerToolset(SelectionToolsetGui(), GUI_IN_TOOLBAR) registerPluginToolset() self.registerHelpToolset(HelpToolsetGui(), GUI_IN_MENUBAR|GUI_IN_TOOLBAR) # Register modules. # self.registerModule('Part', 'Part') 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')
The abaqusGui module provides access to the entire Abaqus GUI Toolkit in addition to the modules, such as FileToolsetGui, that must be registered with the main window.
The first statement in the CaeMainWindow constructor initializes the class by calling the base class constructor. In general, you should always call the base class constructor of the class from which you are deriving, unless you know that you will overwrite the functionality of the class.
Toolsets that are registered with the main window, as opposed to being registered with a module, are available in the GUI when the application first starts up. In addition, toolsets that are registered with the main window remain available throughout a session as the user switches modules.
To register a toolset, you call the registerToolset method and pass in an instance of the toolset class. You can register a help toolset with the application using the registerHelpToolset method. A toolset that is registered in this manner always appears to the right of all other menus in the menu bar. For more information, see “Registering toolsets,” Section 8.2.6.
Note: Every application must register viewManipToolsetGui.
Registering modules puts the module names into the Module combo box in the context bar. The order in which the modules are registered is the order in which the modules will appear in the Module combo box in the context bar.
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.