Warning dialog boxes have the following characteristics:
To find out which button in the warning dialog box was pressed by the user, you must pass the warning dialog box a target and a selector and you must create a message map entry in the form to handle that message. In your message handler you can query the warning dialog box using the getPressedButtonId method. The following examples illustrate how to create a warning dialog box: You must define an ID in the form class: from abaqusGui import * class MyForm(AFXForm): [ ID_WARNING, ] = range(AFXForm.ID_LAST, AFXForm.ID_LAST+1) def __init__(self, owner): # Construct the base class. # AFXForm.__init__(self, owner) FXMAPFUNC(self, SEL_COMMAND, self.ID_WARNING, MyForm.onCmdWarning) ... def doCustomChecks(self): if <someCondition>: showAFXWarningDialog( self.getCurrentDialog(), 'Save changes made in the dialog?', AFXDialog.YES | AFXDialog.NO, self, self.ID_WARNING) return False return True def onCmdWarning(self, sender, sel, ptr): if sender.getPressedButtonId() == \ AFXDialog.ID_CLICKED_YES: self.issueCommands() elif sender.getPressedButtonId() == \ AFXDialog.ID_CLICKED_NO: self.deactivate() Figure 1. An example of a warning dialog box from
showAFXWarningDialog.
There are two other variations of warning dialog boxes:
The dialog box created by showAFXDismissableWarningDialog contains a check button that allows the user to specify whether the application should continue to post the warning dialog box each time the warning occurs. You can check the state of the button by calling the getCheckButtonState method of the warning dialog. The dialog box created by showAFXItemsWarningDialog contains a scrolled list of items to be displayed to the user. The list prevents the dialog box from becoming too tall when it is displaying a long list of items. |