Zenity"> ]>
Zenity Manual 2003 Sun Microsystems GNOME Documentation Project Version 1.0 of Zenity Manual Feedback Information To report a bug or make a suggestion regarding this application or this documentation, please see the GNOME Feedback Page Glynn Foster GNOME Documentation Project Nicholas Curran GNOME Documentation Project 1.0 18-01-2003 Glynn Foster GNOME Documentation Project Introduction &app; displays simple GNOME dialogs. &app; can display the following dialogs: Calendar dialog. Text entry dialog. Various message dialogs including: Error dialog. Information dialog. Question dialog. Warning dialog. File selection dialog. List options dialog. Progress dialog. Text dialog. Basic Use &app; creates simple dialogs. You can use &app; to create a script that interacts graphically with the user. When the user closes the dialog, &app; prints text produced by the dialog to standard error. Ensure that all arguments to &app; are surrounded by quotes. For example, use zenity --calendar --title="Holiday Planner" instead of zenity --calendar --title=Holiday Planner. If you do not use quotes, you can get unexpected results. NOTE Some dialogs support the use of keyboard mnemonics. To specify the character to use as the mnemonic, place an underscore before that character in the text of the dialog. For example, to specify the 'P' as the keyboard mnemonic in the following sentence, use "_Please choose a name". &app; returns the following exit codes: 0 The user has pressed either 'OK' or 'Close'. 1 The user has pressed either 'Cancel' or closed the dialog through the window functions. -1 An unexpected error has occurred. General Options All dialogs have the following general options: --title=TITLE Specifies the title of a dialog. --window-icon=ICON_PATH Specifies the icon that should appear in the window frame of the dialog. --width=WIDTH Specifies the width of the dialog. --height=HEIGHT Specifies the height of the dialog. Calendar Dialog Use --calendar to create a Calendar dialog. &app; returns the date selected to standad error. The current date will be used by the dialog if no date is given on the command line. The Calendar dialog has the following options: --text=TEXT Specifies the text to appear in the Calendar dialog. --day=DAY Specifies the day to be pre-selected in the Calendar dialog. The day ust be a number between 1 and 31. --month=MONTH Specifies the day to be pre-selected in the Calendar dialog. The day must be a number between 1 and 12. --year=YEAR Specifies the year to be pre-selected in the Calendar dialog. --date-format=FORMAT Specifies the format to be returned from the Calendar dialog after the selection has been made. The default format depends on your locale. The format must be of strftime style, for example "%A %d/%m%y". The following script is an example of how to use the Calendar dialog: #!/bin/sh if zenity --calendar --title="Calendar selection" --text="Select a date from below" --day=18 --month=1 --year=2003 then echo $? else echo "No date selected" fi
Calendar dialog example &app; Calendar dialog example
Text Entry Dialog Use --entry to create a Text Entry dialog. &app; returns the contents of the text entry to standard error. The Text Entry dialog has the following options: --text=TEXT Specifies the text to appear in the Text Entry dialog. --entry-text=TEXT Specifies the text to appear in the entry field of the Text Entry dialog. --hide-text Specifies that the text in the entry field of the Text Entry dialog be hidden. The following script is an example of how to use the Text Entry dialog: #!/bin/sh if zenity --entry --title="Add a new entry" --text="Enter your _Password" --hide-text then echo $? else echo "No password entered" fi
Text Entry dialog example &app; Text Entry dialog example
Message Dialogs &app; can create four types of message dialog. Use the --text option to set the text shown in the dialog. Warning Dialog Use --warning to create a Warning dialog. The following script is an example of how to use the Warning message dialog: #!/bin/bash FILE_TYPE=$(file -b $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS|awk '{ print $1}') if [ "$FILE_TYPE" != "PNG" ]; then zenity --warning --text="Could not rotate image :" --hide-text fi
Warning dialog example &app; Warning dialog example
Error Dialog Use --error to create an Error dialog.
Error dialog example &app; Error dialog example
Information Dialog Use --info to create an Information dialog.
Informational dialog example &app; Informational dialog example
Question Dialog Use --question to create a Question dialog.
Question dialog example &app; Question dialog example
File Selection Dialog Use --file-selection to create a file selection dialog. &app; returns the files or directories selected to standard error. The File Selection dialog has the following options: --filename=FILENAME Specifies the file or directory to be selected in the File Selection dialog when the dialog is first shown. --multiple Allows selection of multiple filenames in the File Selection dialog. --separator=SEPARATOR Specifies the string used to divide the returned list of filenames. The following script is an example of how to use the 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 "No file selected.";; esac
File Selection dialog example &app; File Selection dialog example
List Dialog Use --list to create a list dialog. &app; returns the entries in the first column of text of selected rows to standard error. Every column must be specified by the --column option. 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. If you use the --checklist or --radiolist options, each row must start with either 'TRUE' or 'FALSE'. The List dialog has the following options: --text=TEXT Specifies the text to appear in the List dialog. --column=COLUMN Specifies the column headers to appear in the List dialog. You must call the --column option for each column you want to appear in the dialog. --checklist Specifies that the first column should contain check boxes in the List dialog. --radiolist Specifies that the first column should contain radio boxes in the List dialog. --editable Allows the displayed items to be edited. --seperator=SEPERATOR Specifies what string should be used when the List dialog returns the selected entries. The following commandline is an example of how to use the List dialog: zenity --list --title="Choose bugs you wish to view" \ --text="Select items from the list below." \ --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"
List Selection dialog example &app; List dialog example
Progress Dialog Use --progress to create a Progress dialog. &app; reads data from standard input line by line. If a line is prefixed with a hash (#), the text is updated with the text on that line. If a line contains only a number, the percentage is updated with that number. The Progress dialog has the following options: --text=TEXT Specifies the text to appear in the Progress dialog. --percentage=PERCENTAGE Specifies the initial percentage that should be set in the Progress dialog. --auto-close Closes the progress dialog when 100% has been reached. --pulsate Specifies that the Progress dialog should pulsate until an EOF character is read from standard input. The following script is an example of how to use the 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 cancelled." fi
Progress dialog example &app; Progress dialog example
Text Information Dialog Use --text-info to create a Text Information dialog. The Text Information dialog has the following options: --filename=FILENAME Specifies a file to be loaded in the Text Information dialog. --editable Allows the displayed text to be edited. The edited text is returned to standard error when the dialog is closed. The following script is an example of how to use the Text Infomation dialog: #!/bin/sh FILE=`zenity --file-selection --title="Select a file"' case $? in 0) zenity --text-info --title=$FILE --filename=$FILE --editable 2>/tmp/tmp.txt 1) echo "No file selected.";; -1) echo "No file selected.";; esac
Text Information dialog example &app; Text Information dialog example
Miscellaneous Options &app; has the following miscellaneous options: --about Displays some information about &app;. --version Prints the version number of &app;. License This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, of (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. A copy of the GNU General Public License is included as an appendix to the GNOME Users Guide . You may also obtain a copy of the GNU General Public License from the Free Software Foundation by visiting their Web site or by writing to
Free Software Foundation, Inc. 59 Temple Place - Suite 330 Boston, MA 02111-1307 USA