A complete zenity dialog examples 2
April 22nd, 2007 mysurface Posted in lsof, tee, X11, zenity | Hits: 316566 | 56 Comments »
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.
How to create zenity progress dialog?
Progress dialog is to track a progression of a routine, it can be anything, let say I want store the results list of open files (lsof) into a file call lsof.txt, and uses zenity progress to track the progression, I do this:
gksudo lsof | tee >(zenity --progress --pulsate) >lsof.txt

I need to use tee, because without using tee, zenity will strip off my result output. Check out tee examples for more information.
How to create zenity question dialog?
zenity --question --text "Are you sure you want to shutdown?"; echo $?
As echo $? returns result 0 means user press yes, 1 means cancel.

How to create zenity warning dialog?
zenity --warning --text "This will kill, are you sure?";echo $?

How to create zenity scale dialog?
Scale dialog allows you to set a range of number, so that user are force to pick a number within the range.
ans=$(zenity --scale --text "pick a number" --min-value=2 --max-value=100 --value=2 --step 2);echo $ans

How to create zenity text info dialog?
Text Info can be very useful to display text out to a GUI. I use back the lsof examples, but this time I feed the results to text info box.
gksudo lsof | zenity --text-info --width 530

As you can see, you can specified the width and height of a zenity dialog. Too bad, text info dialog do not have option to disable text wrap and specified what font to use.
How to create zenity list dialog?
List dialog is the most flexible dialog and I have spend quite sometimes to utilize the usage. As it can generate multiple columns, multiple selection, checklist, radiolist etc. checkout –help-list for more information.
This is for radiolist:
ans=$(zenity --list --text "Is linux.byexamples.com helpful?" --radiolist --column "Pick" --column "Opinion" TRUE Amazing FALSE Average FALSE "Difficult to follow" FALSE "Not helpful"); echo $ans

First you need to define a columns, then feed all the list options one by one.
This is for checklist:
ans=$(zenity --list --text "How linux.byexamples can be improved?" --checklist --column "Pick" --column "options" TRUE "More pictures" TRUE "More complete post" FALSE "Includes Installation guidelines" FALSE "Create a forum for question queries" --separator=":"); echo $ans

The result this time will be long and probably more than one, so you can spefify a separator to differentiate them.
[tags]GUI dialog, GTK+, GUI programming[/tags]







April 22nd, 2007 at 5:48 pm
[...] Check out A complete zenity dialog examples 2. Related Posts A complete zenity dialog examples 2This is a continues post of A complete zenity dialog examples 1, in this post we will covers zenity dialog for progress,… using GUI dialog boxEvery GUI program has its command line, even dialog boxes too. zenity for gnome, kdialog for KDE, xmessage for other win… windows user access ssh through puttyPutty is a great ssh client for windows user, it is easy to use and lightweight too. Do you expect to see a tutorial or … [...]
April 24th, 2007 at 2:42 pm
Hello
This is a very useful information, I was searching the web 2days to get such information. Exellent
April 25th, 2007 at 8:04 pm
Anothr feed track -Linux by Examples…
One new subscriber from Anothr Alerts…
April 26th, 2007 at 11:28 pm
Nice tutorial guide for on zenity :)
It’s a nice tutorial..Zenity can also be used to transfer your bash script into gui front-end, for example i used zenity to run my campus local repo on top of https :)
Check out here http://y0nd13.blogspot.com/2007/04/what-heck.html
August 29th, 2007 at 1:15 am
The example for the progress dialog could be better. Rather than copping out with the –pulsate option, it would’ve been nice to see how you actually get it to track a job.
Good stuff, otherwise.
September 15th, 2007 at 4:23 am
To send progress you send percentage numbers. The following is an example (all on one line, of course).
(for ((i=0;i<100;i+=4)) ; do echo $i ; sleep 1; done) | zenity –progress –auto-close
In scripts I often create a function and generate the progress values from the function, redirecting the output. Another simple example.
function pro () {
read -p “Question 1″
echo “25″
read -p “Question 2″
echo “50″
read -p “Question 3″
echo “75″
read -p “Question 4″
echo “100″
}
pro | zenity –progress –auto-close
[edited by mysurface]
September 15th, 2007 at 4:25 am
Hmm… Trimmed my last comment because of the less-than. Let’s try this again!
(for ((i=0;i<100;i+=4)) ; do echo $i ; sleep 1; done) | zenity –progress –auto-close
September 15th, 2007 at 6:59 am
Thanks Stacy, very informative. I like the function pro(), make good use of zenity progressing dialog.
December 31st, 2007 at 11:48 am
[...] is here A complete zenity dialog examples 1Â & A complete zenity dialog examples 2. 2007-12-31 11:48 by admin, Filed under:Linux No Comments [...]
April 24th, 2009 at 3:57 pm
Thank’s
June 23rd, 2009 at 12:24 am
is there a way to disable the cancel and close button on a dialog
June 23rd, 2009 at 12:25 am
Is there a way to disable the cancel and close buttons in zenity?
January 17th, 2010 at 9:23 pm
Thank you for the example of zenity –list :) Could you please tell me what is the GTK theme you used in the screenshots ?
August 31st, 2010 at 9:53 pm
Is there a way to specify font size? I have a consent paragraph and the display is not completely visible.
September 30th, 2010 at 3:42 pm
@stacy, How about this?
(for i in $(seq 0 4 100); do echo $i; sleep 1; done)|zenity –progress –auto-close
January 4th, 2011 at 8:09 am
Couldn’t concur far more with this, really attractive posting. Thank You.
February 18th, 2011 at 4:34 pm
PF Changs Menu
March 11th, 2011 at 10:53 pm
Thank for information. I will back again.
March 12th, 2011 at 1:16 am
Great ideas. I look forward to reading more of your posts.
April 4th, 2011 at 12:57 am
Basically to follow up on the update of this topic on your site and would like to let you know how much I appreciated the time you took to write this useful post. In the post, you spoke of how to really handle this issue with all convenience. It would be my pleasure to gather some more ideas from your site and come up to offer others what I have learned from you. I appreciate your usual great effort.
April 9th, 2011 at 6:06 pm
Hi! Thanks! It works, and it was very helpful :)
April 17th, 2011 at 5:18 pm
Is a good idea. I will be told to
April 27th, 2011 at 8:09 am
I am really impressed with your writing skills and also with the layout on your blog. Is this a paid theme or did you customize it yourself? Anyway keep up the nice quality writing, it is rare to see a great blog like this one nowadays..
May 13th, 2011 at 6:18 pm
some truly nice and useful info on this website , too I conceive the design contains great features.
May 15th, 2011 at 11:14 pm
Thanks for your personal marvelous posting! I definitely enjoyed reading it, you’re a great author.I will be sure to bookmark your blog and will come back later on. I want to encourage one to continue your great posts, have a nice morning!
May 18th, 2011 at 3:08 am
I´m starting with Zenit now, Your blog is a bible for me now…
May 18th, 2011 at 10:05 am
The following time I read a blog, I hope that it doesnt disappoint me as much as this one. I mean, I do know it was my option to read, however I truly thought youd have one thing fascinating to say. All I hear is a bunch of whining about something that you can repair when you werent too busy on the lookout for attention.
May 18th, 2011 at 9:43 pm
Thanks for a great take. You really gave us something to think about. Even though there is the global economic crisis, an increasing number of products are being made in China. Therefore, China is becoming a world leader.
May 18th, 2011 at 9:45 pm
My brother suggested I might like this blog. He was totally right. This post truly made my day. You cann’t imagine just how much time I had spent for this Game info! Thanks!
May 19th, 2011 at 3:16 am
Aw, this was a really nice post. In thought I want to put in writing like this moreover – taking time and precise effort to make an excellent article… however what can I say… I procrastinate alot and certainly not appear to get one thing done.
June 1st, 2011 at 5:04 pm
Hi,
I am new to zenity. Cud u suggest if its possible to have more than 1 dialogue for a perticular zenity (e.g. I want to create a GUI where the user has to fill his Name n Age). Thanks in adv.
June 3rd, 2011 at 5:08 pm
Zenity is simple, what people usually do is call the entry dialog for each question.
June 10th, 2011 at 12:07 am
I loved as much as you’ll receive carried out right here. The sketch is tasteful, your authored material stylish. nonetheless, you command get bought an impatience over that you wish be delivering the following. unwell unquestionably come further formerly again since exactly the same nearly very often inside case you shield this increase.
June 17th, 2011 at 1:51 pm
#!/usr/bin/perl
$var=FALSE “abcd” FALSE “defg”;
now I want to use this $var in any zenity.
please help………….
June 26th, 2011 at 4:37 am
Thank you for this valuable information, so nice seeing the community post this kind.
July 4th, 2011 at 2:11 am
I have problem on zenity –list when using variable
for example
DATA=”FALSE Banana \”The fruit that has yellow color\”"
zenity –list –checklist –column “choose” –column “fruit” –column “description” $DATA
The result is not as I expected
I want to display
+——-+——–+———————————+
|choose | fruit | description |
+——-+——–+———————————+
| [ ] | Banana | The fruit that has yellow color |
+——-+——–+———————————+
but I got
+——-+——–+———————————+
|choose | fruit | description |
+——-+——–+———————————+
| [ ] | Banana | “The |
+——-+——–+———————————+
| [ ] | that | has |
+——-+——–+———————————+
| [ ] | color | |
+——-+——–+———————————+
July 11th, 2011 at 6:07 am
Great post as always appreciate the good read thanks.
July 12th, 2011 at 2:50 am
I am often to blogging and i really appreciate your content The article has really peaks my interest I am going to bookmark your site and keep checking for new information
August 24th, 2011 at 1:31 pm
Good write-up, I’m regular visitor of one’s website, maintain up the excellent operate, and It is going to be a regular visitor for a long time.
August 25th, 2011 at 2:00 pm
how to display two or more entry field in zenity ???
September 4th, 2011 at 1:48 pm
thanks for the info I’m always here checking out your great site.
September 4th, 2011 at 3:15 pm
Confucius~ Only the wisest and stupidest of men never change.
September 9th, 2011 at 9:43 pm
I like what you guys tend to be up too. This sort of clever work and reporting! Keep up the terrific works guys I’ve included you guys to blogroll.
September 22nd, 2011 at 3:54 am
@awaludin
I got the same problem. Nobody knows solution?
OPTIONS=’FALSE “asdfds asdfds” TRUE “asdf asdasd”‘
$(zenity –height=400 –width=400 –list –text “which?” –radiolist –column “check! ” –column “Choice” $OPTIONS );
this does not work either…
October 18th, 2011 at 6:29 am
Is there a way to display a file in zenity and at the same time ask for user input? For example..you cat a file into a info box and at the bottom ask for user input? Or how do you do display a file in an entry box?
November 21st, 2011 at 1:21 pm
[...] zenity? I run Fedora, and have successfully used zenity within cron a few times. Have a look here – http://linux.byexamples.com/archives…og-examples-2/ Cheers, [...]
November 26th, 2011 at 5:50 am
This article helped me with a problem I was having with zenity. Thanks!
January 7th, 2012 at 1:24 am
[...] http://linux.byexamples.com/archives/265/a-complete-zenity-dialog-examples-2/ Share this:TwitterFacebookLike this:LikeBe the first to like this [...]
June 17th, 2012 at 2:07 pm
Hi there to every one, it’s in fact a good for me to go to see this web page, it includes helpful Information.
June 29th, 2012 at 10:16 pm
[...] ??????? ???? ??????????? xrandr’?? ? ???? ????? ? ???? ??????????? zenity (??? ???????????? ???? ?????? ??????????) ? [...]
November 17th, 2012 at 4:17 am
Amazing! Thks!
January 5th, 2013 at 3:11 am
Very helpful
thx
March 30th, 2013 at 11:02 am
Hello there! Your post rocks too as getting a reputable superb recognize!??
April 10th, 2013 at 11:43 am
Thanks to your nice blog. I enjoy your writing.
April 14th, 2013 at 1:58 am
[...] http://linux.byexamples.com/archives/265/a-complete-zenity-dialog-examples-2/ [...]
May 7th, 2013 at 1:59 am
Having problem putting dialog into PRE login warning. Got the box w/ Close to come up pre login, but ….anyone have examples on how the script should look for the text to show up in the box?
Thanks.
jade