+ Use the
+ The calendar dialog supports the following options: +
+ +Specifies the text that is displayed in the calendar dialog.
+Specifies the day that is selected in the calendar dialog. day must be a number between 1 and 31 inclusive.
+Specifies the month that is selected in the calendar dialog. month must be a number between 1 and 12 inclusive.
+Specifies the year that is selected in the calendar dialog.
+Specifies the format that is returned from the calendar dialog after date selection. The default format depends on your locale. Format must be a format that is acceptable to the
+ The following example script shows how to create a calendar dialog: +
+ +
+#!/bin/sh
+
+
+if zenity --calendar \
+--title="Select a Date" \
+--text="Click on a date to select that date." \
+--day=10 --month=8 --year=2004
+ then echo $?
+ else echo "No date selected"
+fi
+
+
+
+
+
+ Use the
+ The color selection dialog supports the following options: +
+ +Set the initial color.(ex: #FF0000)
+Show the palette.
++ The following example script shows how to create a color selection dialog: +
+ +
+#!/bin/sh
+
+COLOR=`zenity --color-selection --show-palette`
+
+case $? in
+ 0)
+ echo "You selected $COLOR.";;
+ 1)
+ echo "No color selected.";;
+ -1)
+ echo "An unexpected error has occurred.";;
+esac
+
+
+
+
+
+ Use the
+ The text entry dialog supports the following options: +
+ +Specifies the text that is displayed in the text entry dialog.
+Specifies the text that is displayed in the entry field of the text entry dialog.
+Hides the text in the entry field of the text entry dialog.
++ The following example script shows how to create a text entry dialog: +
+ +
+#!/bin/sh
+
+if zenity --entry \
+--title="Add new profile" \
+--text="Enter name of new profile:" \
+--entry-text "NewProfile"
+ then echo $?
+ else echo "No name entered"
+fi
+
+
+
+
+
+ Use the
+ The following example script shows how to create an error dialog: +
+ +
+#!/bin/bash
+
+zenity --error \
+--text="Could not find /var/log/syslog."
+
+
+
+
+
+ Use the
+ The file selection dialog supports the following options: +
+ +Specifies the file or directory that is selected in the file selection dialog when the dialog is first shown.
+Allows the selection of multiple filenames in the file selection dialog.
+Allows only selection of directories in the file selection dialog.
+Set the file selection dialog into save mode.
+Specifies the string that is used to divide the returned list of filenames.
++ The following example script shows how to create a file selection dialog: +
+ +
+#!/bin/sh
+
+FILE=`zenity --file-selection --title="Select a File"`
+
+case $? in
+ 0)
+ echo "\"$FILE\" selected.";;
+ 1)
+ echo "No file selected.";;
+ -1)
+ echo "An unexpected error has occurred.";;
+esac
+
+
+
+
+ Use the
+ The forms dialog supports the following options: +
+ +Add a new Entry in forms dialog.
+Add a new Password Entry in forms dialog. (Hide text)
+Add a new Calendar in forms dialog.
+Set the dialog text.
+Set output separator character. (Default: | )
+Set the format for the returned date. The default format depends on your locale. format must be a Format that is acceptable to the
+ The following example script shows how to create a forms dialog: +
+ +
+#!/bin/sh
+
+zenity --forms --title="Add Friend" \
+ --text="Enter information about your friend." \
+ --separator="," \
+ --add-entry="First Name" \
+ --add-entry="Family Name" \
+ --add-entry="Email" \
+ --add-calendar="Birthday" >> addr.csv
+
+case $? in
+ 0)
+ echo "Friend added.";;
+ 1)
+ echo "No friend added."
+ ;;
+ -1)
+ echo "An unexpected error has occurred."
+ ;;
+esac
+
+
+
+
+ Use the
+ The following example script shows how to create an information dialog: +
+ +
+#!/bin/bash
+
+zenity --info \
+--text="Merge complete. Updated 3 of 10 files."
+
+
+
+
+
+
Calendar
File selection
Forms
List
Notification icon
Message
+Error
Information
Question
Warning
Password entry
Progress
Text entry
Text information
Scale
Color selection
+ Use the
+ Data for the dialog must specified column by column, row by row. Data can be provided to the dialog through standard input. Each entry must be separated by a newline character. +
+ +
+ If you use the
+ The list dialog supports the following options: +
+ +Specifies the column headers that are displayed in the list dialog. You must specify a
Specifies that the first column in the list dialog contains check boxes. +
+Specifies that the first column in the list dialog contains radio boxes. +
+Allows the displayed items to be edited. +
+Specifies what string is used when the list dialog returns the selected entries. +
+Specifies what column should be printed out upon selection. The default column is + '1'. 'ALL' can be used to print out all columns in the list. +
++ The following example script shows how to create a list dialog: +
+
+#!/bin/sh
+
+zenity --list \
+ --title="Choose the Bugs You Wish to View" \
+ --column="Bug Number" --column="Severity" --column="Description" \
+ 992383 Normal "GtkTreeView crashes on multiple selections" \
+ 293823 High "GNOME Dictionary does not handle proxy" \
+ 393823 Critical "Menu editing does not work in GNOME 2.0"
+
+
+
+
+
+For each type, use the
+ Use the
Specifies the text that is displayed in the notification area.
++ The following example script shows how to create a notification icon: +
+
+#!/bin/sh
+
+zenity --notification\
+ --window-icon="info" \
+ --text="There are system updates necessary!"
+
+
+
+
+
+ Use the
+ The password entry dialog supports the following options: +
+ +Display the username field.
++ The following example script shows how to create a password entry dialog: +
+ +
+#!/bin/sh
+
+ENTRY=`zenity --password --username`
+
+case $? in
+ 0)
+ echo "User Name: `echo $ENTRY | cut -d'|' -f1`"
+ echo "Password : `echo $ENTRY | cut -d'|' -f2`"
+ ;;
+ 1)
+ echo "Stop login.";;
+ -1)
+ echo "An unexpected error has occurred.";;
+esac
+
+
+
+
+
+ Use the
+
+ The progress dialog supports the following options: +
+ +Specifies the text that is displayed in the progress dialog.
+Specifies the initial percentage that is set in the progress dialog.
+Closes the progress dialog when 100% has been reached.
+Specifies that the progress bar pulsates until an EOF character is read from standard input.
++ The following example script shows how to create a progress dialog: +
+ +
+#!/bin/sh
+(
+echo "10" ; sleep 1
+echo "# Updating mail logs" ; sleep 1
+echo "20" ; sleep 1
+echo "# Resetting cron jobs" ; sleep 1
+echo "50" ; sleep 1
+echo "This line will just be ignored" ; sleep 1
+echo "75" ; sleep 1
+echo "# Rebooting system" ; sleep 1
+echo "100" ; sleep 1
+) |
+zenity --progress \
+ --title="Update System Logs" \
+ --text="Scanning mail logs..." \
+ --percentage=0
+
+if [ "$?" = -1 ] ; then
+ zenity --error \
+ --text="Update canceled."
+fi
+
+
+
+
+
+ Use the
+ The following example script shows how to create a question dialog: +
+ +
+#!/bin/bash
+
+zenity --question \
+--text="Are you sure you wish to proceed?"
+
+
+
+
+
+ Use the
+ The scale dialog supports the following options: +
+ +Set the dialog text. (Default: Adjust the scale value)
+Set initial value. (Default: 0) You must specify value between minimum value to maximum value.
+Set minimum value. (Default: 0)
+Set maximum value. (Default: 100)
+Set step size. (Default: 1)
+Print value to standard output, whenever a value is changed.
+Hide value on dialog.
++ The following example script shows how to create a scale dialog: +
+ +
+#!/bin/sh
+
+VALUE=`zenity --scale --text="Select window transparency." --value=50`
+
+case $? in
+ 0)
+ echo "You selected $VALUE%.";;
+ 1)
+ echo "No value selected.";;
+ -1)
+ echo "An unexpected error has occurred.";;
+esac
+
+
+
+
+
+ Use the
+ The text information dialog supports the following options: +
+ +Specifies a file that is loaded in the text information dialog.
+Allows the displayed text to be edited. The edited text is returned to standard output when the dialog is closed.
+Specifies the text font.
+Enable a checkbox for use like a 'I read and accept the terms.'
+Enable html support.
+Sets an url instead of a file. Only works if you use --html option.
++ The following example script shows how to create a text information dialog: +
+ +
+#!/bin/sh
+
+# You must place file "COPYING" in same folder of this script.
+FILE=`dirname $0`/COPYING
+
+zenity --text-info \
+ --title="License" \
+ --filename=$FILE \
+ --checkbox="I read and accept the terms."
+
+case $? in
+ 0)
+ echo "Start installation!"
+ # next step
+ ;;
+ 1)
+ echo "Stop installation!"
+ ;;
+ -1)
+ echo "An unexpected error has occurred."
+ ;;
+esac
+
+
+
+
+ When you write scripts, you can use
+ You can create a dialog to obtain information from the user. For example, you can prompt the user to select a date from a calendar dialog, or to select a file from a file selection dialog. +
++ You can create a dialog to provide the user with information. For example, you can use a progress dialog to indicate the current status of an operation, or use a warning message dialog to alert the user. +
+
+ When the user closes the dialog,
+ When you write
For example, use:
+Do not use:
++ If you do not use quotation marks, you might get unexpected results. +
++ An access key is a key that enables you to perform an action from the keyboard rather than use the mouse to choose a command from a menu or dialog. Each access key is identified by an underlined letter on a menu or dialog option. +
+
+ Some
+ Zenity returns the following exit codes: +
+ +
+ Exit Code |
+
+ Description |
+
+ 0 + |
+
+ The user has pressed either |
+
+ 1 + |
+
+ The user has either pressed |
+
+ -1 + |
+
+ An unexpected error has occurred. + |
+
+ 5 + |
+
+ The dialog has been closed because the timeout has been reached. + |
+
+ All Zenity dialogs support the following general options: +
+ +Specifies the title of a dialog.
+Specifies the icon that is displayed in the window frame of the dialog. There are + 4 stock icons also available by providing the following keywords - 'info', 'warning', 'question' and + 'error'. +
+Specifies the width of the dialog.
+Specifies the height of the dialog.
+Specifies the timeout in seconds after which the dialog is closed.
++ Zenity provides the following help options: +
+ +Displays shortened help text.
+Displays full help text for all dialogs.
+Displays help text for general dialog options.
+Displays help text for calendar dialog options.
+Displays help text for text entry dialog options.
+Displays help text for error dialog options.
+Displays help text for information dialog options.
+Displays help text for file selection dialog options.
+Displays help text for list dialog options.
+Displays help text for notification icon options.
+Displays help text for progress dialog options.
+Displays help text for question dialog options.
+Displays help text for warning dialog options.
+Displays help for text information dialog options.
+Displays help for miscellaneous options.
+Displays help for GTK+ options.
++ Zenity also provides the following miscellaneous options: +
+ +Displays the
Displays the version number of Zenity.
+
+ Zenity supports the standard GTK+ options. For more information about the GTK+ options, execute the
+ Normally, Zenity detects the terminal window from which it was launched + and keeps itself above that window. This behavior can be disabled by + unsetting the WINDOWID environment variable. +
+ +
+ Use the
+ The following example script shows how to create a warning dialog: +
+ +
+#!/bin/bash
+
+zenity --warning \
+--text="Disconnect the power cable to avoid electrical shock."
+
+
+
+
+