To modify widgets in the toolset, you need to be able to access them. The following functions in the Abaqus GUI Toolkit allow you to access a widget:
The following example shows how you can modify the Figure 1 shows the menu before and after the script is executed. toolset GUI.from sessionGui import FileToolsetGui from myIcons import boltToolboxIconData from myForm import MyForm class MyFileToolsetGui(FileToolsetGui): #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def __init__(self): # Construct the base class. # FileToolsetGui.__init__(self) # Remove unwanted items from the File menu, # including the second separator. # menubar = getAFXApp().getAFXMainWindow().getMenubar() menu = getWidgetFromText(menubar, 'File').getMenu() getWidgetFromText(menu, 'New').hide() getWidgetFromText(menu, 'Save').hide() getWidgetFromText(menu, 'Save As...').hide() getSeparator(menu, 2).hide() # Remove unwanted items from the toolbar # toolbar = self.getToolbarGroup('File') getWidgetFromText(toolbar, 'New Model\nDatabase').hide() getWidgetFromText(toolbar, 'Save Model\nDatabase').hide() # Add an item to the File menu just above Exit # btn = AFXMenuCommand(self, menu, 'Custom Button...', None, MyForm(self), AFXMode.ID_ACTIVATE) sep = getSeparator(menu, 6) btn.linkBefore(sep) # Rename the File menu # fileMenu = getWidgetFromText(menubar, 'File') fileMenu.setText('MyFile') # Change a toolbar button icon # btn = getWidgetFromText(toolbar, 'Open') icon = FXXPMIcon(getAFXApp(), boltToolboxIconData) btn.setIcon(icon) This example script illustrates the following:
|