Displaying Message Dialogs
The MessageBox class in the hec.script module, and the MessageDialog class in the
MessageDialog module have several functions used to display messages in message box
dialogs. The dialogs can be one of four different types: Error, Warning, Informational or
Plain. The difference between the MessageBox functions and their MessageDialog
counterparts is the MessageBox versions do not allow interaction with any object other
than the message box itself, while the MessageDialog versions allow the user to interact
with the HecDssVue program window, as well as any displayed tables or plots while the
message box is displayed. If MessageDialog functions are used in a script that is to be
executed other than from the command line, they must not be used in the main script
thread.
MessageBox and MessageDialog functions with multiple buttons return a string containing the text of the button that was selected to dismiss the message box.
Note: Do not use the MessageBox or MessageDialog functions in a script that is to
run unattended since these functions cause scripts to pause for user interaction.
MessageBox and MesssageDialog functions are described in the table below.
MessageBox and MessageDialog Functions
|
Function |
Returns |
Comments |
|
showError(string message, string title)
|
None |
Display an error dialog to you with the message and title |
|
showWarning(string message, string title)
|
None |
Display a warning dialog to you with the message and title |
|
showInformation(string message, string title) |
None |
Display a Informational dialog to you with the message and title |
|
showPlain(string message, string title) |
None |
Display a plain dialog to you with the message and title |
|
showYesNo(string message, string title) |
string |
Display a Yes/No dialog to you with the message and title |
|
showYesNoCancel(string message, string title) |
string |
Display a Yes/No/Cancel dialog to you with the message and title |
|
showOkCancel(string message, string title) |
string |
Display a Ok/Cancel dialog to you with the message and title |
|
Example: Display Error Dialog with MessageBox class
from hec.script import *
MessageBox.showError("An Error Occurred”, "Error") |
|
Example: Display OK/Cancel Dialog with MessageDialog class
from hec.script import * import MessageDialog import thread def main() : ok=MessageDialog.showOkCancel(“Continue with Operation”, “Confirm”) thread.start_new_thread(main, ()) |