Using different tyes of dialog boxes

This section shows you how to create and display different types of dialogs. For all the examples, we'll be using a width of 250 and a height of 150 in place of <width> and <height> for the width and height of the dialog box to be displayed.

Creating a Confirmation Dialog

You can create a dialog box that shows a question and a "Yes" and a "No" button using the --yesno option. For example, to create a dialog box with the title as "My Dialog", and question to be shown "Should I exit ?" use the following command gdialog --title "My Dialog" --yesno "Should I exit ?" 250 150

The above command displays the dialog box shown in figure Figure 2.

Figure 2. confirmation box example

The return value from gdialog is 0 if the user clicked on "Yes" and 1 if the user clicked on "No". By default, the "Yes" button is highlighted when the dialog is displayed. In case you want the "No" button to be highlighted, add --defaultno

Creating a Message Box

You can create a dialog box that shows a message using the --msgbox option. For example, to create a dialog box with the title as "My Dialog", and message to be shown "Here's a message !" use the following command gdialog --title "My Dialog" --msgbox "Here's a message" 250 150

The above command displays the dialog box shown in figure Figure 3.

Figure 3. Message box example