A complete zenity dialog examples 1
April 22nd, 2007 mysurface Posted in X11, zenity | Hits: 28436 |
Zenity is a tool that help you to create a common functional GTK+ dialogs. It have various dialogs that each of them have different ways of presenting data and acquire data from user input.
We have introduce how to make use of GUI dialog box in Using GUI dialog box, where we give an example of how zenity create a question dialog box. Besides question dialog box, zenity can create more than that, such as calendar, entry, error, info, file selection, list, notification, progress, warning, scale and text info. In this tutorial, we would like to illustrate how to create every single zenity dialog by examples.
How to create zenity calendar dialog?
You are allow to specify the initial selection of date in calendar dialog, specified with options –day –month –year. The default selection will be today’s date. Zenity will returns the date selected by user.
szDate=$(zenity --calendar --text "Pick a day" --title "Medical Leave" --day 23 --month 5 --year 2008); echo $szDate

How to create zenity entry dialog?
Entry dialog usually use to acquire string entry from user.
szAnswer=$(zenity --entry --text "where are you?" --entry-text "at home"); echo $szAnswer

How to create zenity error dialog?
Create an error dialog is straight forward, it does not wait for user input.
zenity --error --text "Installation failed! "

How to create zenity info dialog?
zenity --info --text "Join us at irc.freenode.net #lbe."
|
|

How to create zenity File Selection dialog?
File selection dialog is one of the a very useful zenity dialog, it support open file or save file dialog. The best part is, zenity file selection dialog is not difficult to use. Let me show you how to create a save file dialog box, if filename already exists, it will ask for confirmation.
szSavePath=$(zenity --file-selection --save --confirm-overwrite);echo $szSavePath

Check out more and try to create an open file dialog yourself?
zenity --help-file-selection
How to create zenity notification dialog?
To notify users regarding to some status, you can use notification dialog, a tiny icon will be appear at taskbar.
zenity --notification --window-icon=update.png --text "Please update your system."
Next coming up tutorial will covers zenity dialog such as progress, question, warning, scale, text-info and list.
Check out A complete zenity dialog examples 2.
Live Chat!









April 22nd, 2007 at 4:19 pm
[...] This is a continues post of A complete zenity dialog examples 1, in this post we will covers zenity dialog for progress, question, warning, scale, text info and list. [...]
May 12th, 2007 at 10:13 am
thanks I had some troubles to understand some tricks about zenity. this was really usefull. I’m now going to read about awk … gret site.
August 16th, 2007 at 3:49 am
Wow, good work! These examples helped me a lot, thanks!
November 6th, 2007 at 7:16 pm
Il seguente script è solo un esempio per mostrare alcuni componenti richiamabili attraverso zenity
#!/bin/bash
zenity –question –text “Vuoi editare un nuovo file?”
if [ $? = 0 ];
then
SELECTED_FILE=`zenity –file-selection`
zenity –text-info –width=560 –editable –filename=$SELECTED_FILE > $SELECTED_FILE.edited
echo “Saved $SELECTED_FILE as $SELECTED_FILE.edited”
zenity –text-info –filename=$SELECTED_FILE.edited
November 30th, 2007 at 10:08 am
really usefull post!
November 30th, 2007 at 11:09 am
cool
November 30th, 2007 at 10:08 pm
thanks, good post!
June 13th, 2008 at 3:23 pm
[...] dialogs for multi purpose usage, this tutorial illustrate the usage of each dialogs by examples.http://linux.byexamples.com/archives/259/a-complete-zenity-dialog-examples-1/PyGTK 2.0 TutorialThis tutorial describes the use of the Python PyGTK [...]