Understanding different buttons in a dialog box
This recipe will display a dialog box with three buttons: Yes
, Cancel
, and No
. When the user clicks a button, the respective message will be displayed, informing you of which button was pressed by the user. The idea is to understand the response generated when any button is pressed and take action accordingly.
How to do it...
In this recipe, we will be making use of the following methods:
dialogCreateAlert()
: This method is used to display a message via a dialog boxdialogSetPositiveButtonText()
: This method is used to display theYes
button in a dialog boxdialogSetNegativeButtonText()
: This method is used to display theNo
button in a dialog boxdialogSetNeutralButtonText()
: This method is used to display theCancel
button in a dialog boxdialogGetResponse()
: This method is used to take the response from the user via a dialog box
Take a look at the following steps:
- Type the following code in the Python script
demoDialog.py
in the current folder of...