A complete zenity dialog examples 2

April 22nd, 2007 mysurface Posted in lsof, tee, X11, zenity | Hits: 355406 | 65 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

zenity progress dialog

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.
zenity question dialog

How to create zenity warning dialog?

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

zenity warning dialog

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

zenity scale dialog

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

zenity text info dialog

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

zenity list dialog
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

zenity list dialog

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]

65 Responses to “A complete zenity dialog examples 2”

  1. [...] 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 …                              [...]

  2. A/Moniem A/Aal Says:

    Hello

    This is a very useful information, I was searching the web 2days to get such information. Exellent

  3. Anothr feed track -Linux by Examples…

    One new subscriber from Anothr Alerts…

  4. 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

  5. Juan Garbanzo Bean Says:

    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.

  6. 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]

  7. 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

  8. Thanks Stacy, very informative. I like the function pro(), make good use of zenity progressing dialog.

  9. [...] 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 [...]

  10. Thank’s

  11. is there a way to disable the cancel and close button on a dialog

  12. Is there a way to disable the cancel and close buttons in zenity?

  13. Thank you for the example of zenity –list :) Could you please tell me what is the GTK theme you used in the screenshots ?

  14. Is there a way to specify font size? I have a consent paragraph and the display is not completely visible.

  15. @stacy, How about this?

    (for i in $(seq 0 4 100); do echo $i; sleep 1; done)|zenity –progress –auto-close

  16. Couldn’t concur far more with this, really attractive posting. Thank You.

  17. Thank for information. I will back again.

  18. Great ideas. I look forward to reading more of your posts.

  19. 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.

  20. Hi! Thanks! It works, and it was very helpful :)

  21. Is a good idea. I will be told to

  22. 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..

  23. some truly nice and useful info on this website , too I conceive the design contains great features.

  24. 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!

  25. I´m starting with Zenit now, Your blog is a bible for me now…

  26. 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.

  27. 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.

  28. 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!

  29. 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.

  30. Debashish Says:

    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.

  31. Zenity is simple, what people usually do is call the entry dialog for each question.

  32. 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.

  33. #!/usr/bin/perl
    $var=FALSE “abcd” FALSE “defg”;
    now I want to use this $var in any zenity.
    please help………….

  34. Thank you for this valuable information, so nice seeing the community post this kind.

  35. 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 | |
    +——-+——–+———————————+

  36. Great post as always appreciate the good read thanks.

  37. 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

  38. 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.

  39. how to display two or more entry field in zenity ???

  40. thanks for the info I’m always here checking out your great site.

  41. Confucius~ Only the wisest and stupidest of men never change.

  42. 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.

  43. @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…

  44. 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?

  45. [...] 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, [...]

  46. This article helped me with a problem I was having with zenity. Thanks!

  47. [...] http://linux.byexamples.com/archives/265/a-complete-zenity-dialog-examples-2/ Share this:TwitterFacebookLike this:LikeBe the first to like this [...]

  48. Hi there to every one, it’s in fact a good for me to go to see this web page, it includes helpful Information.

  49. [...] ??????? ???? ??????????? xrandr’?? ? ???? ????? ? ???? ??????????? zenity (??? ???????????? ???? ?????? ??????????) ? [...]

  50. Amazing! Thks!

  51. Edison Bustos Says:

    Very helpful
    thx

  52. Hello there! Your post rocks too as getting a reputable superb recognize!??

  53. Thanks to your nice blog. I enjoy your writing.

  54. 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

  55. I want to to thank you for this fantastic read!! I
    definitely enjoyed every little bit of it. I have you book-marked to check out new stuff you post…

  56. Sunglasses are all-around for any prolonged time. They’ve always been deemed as items of style and style. Several individuals have often associated sunglasses with appears of sleekness without having any practical purpose. Celebrities have been regarded to make use of sunglasses to help hide their faces from your stares of their fans. In spite of the ignorance of most of the people as to the sensible importance of sunglasses, their reputation has grown steadily. It really is unusual to discover someone without a pair of sunglasses in particular throughout the summertime. People with out their sunglasses on possibly have them stashed away someplace within their closets. Contrary to typical perception nevertheless, sunglasses have numerous health rewards some of which could be viewed beneath.

  57. Khaitan have been proved as top industries in the world for the styles. They have produced fans which consume less energy and also give fresh cool air. Although not all gaming computers cost a fortune, the ones that do are really worth paying for. Gaming computers are not only great for gaming, but they are a great computer over all. space jams for sale http://www.google.fr/webmasters/tools/richsnippets?url=run2013.org/ceshi12.html

  58. The Air Jordan IV took the world by storm in 1989. Along with a career season came a career sneaker. Fatsia can be planted as a large specimen plant, or containerized Fatsia will grow as the shrub as an indoor plant. Philodendron selloum is often used like Fatsia, and can grow into a large, attractive specimen plant on slender, woody-looking trunks (stems). space jams for sale http://www.google.si/webmasters/tools/richsnippets?url=run2013.org/ceshi9.html

  59. Add in the partially ground oats and mix gently to combine. Avoid mashing and over-mixing. Weekender: To Better Remember Latest Highest rated Most watched Most discussed rift requirements Indeed, nothing distinguishes Rift from its competitors quite like its rapid fire content updates. You see, I love the ideas, the polish, and the passion behind Rift, but I’ve never warmed to the game itself. jordan retro 13 http://www.google.tl/webmasters/tools/richsnippets?url=run2013.org/ceshi12.html

  60. A softly outlook Once consumed, the 358 is paradoxically a yielding outlook : the 47 mm of diameter enables a cyclopean dole from the 170 grams of heaviness (that is agreeable to reason regarding how big the horologue, because of the titanium). Enhanced comfort is great, especially if it’s decayed about the left hands since the crown safety doesn’t crowd about the wrist. Just the the third dimension can flinch but tribe get ordinary to it swiftly. The readability is intellectual in each and every locality because of the abstemiousness from the sun-dial and also to the clutches which are generously covered with Super Luminova. Panerai Luminor Watches The flexure bezel is simple to rule. The clicks are unswerving and tight. It exudes solidity. Another strap, ideal for the diving As some chivalrous proprietor will maybe go dabbling some octopuses or sun rays with this particular strict toy, Panerai provides another specifical diving nylon bodily thong on the broach that can take in the lever mainspring from the crown protection. Well musing, it appears of the inexhaustible firmness and enables modifying the dimensions of the strap to every millimeter, that is convenient when putting on diving suite. Inference To cause to approach a conclusion, this scrap doesn’t incompetent arguments. It’ll please both fire-brand fanatics that need to have an exclusive bit, too for the amateurs of outermost diving watches who definitely are lured by its impeccable making.

  61. 886539 530250Write more, thats all I have to say. Literally, it seems as though you relied on the video to make your point. You clearly know what youre talking about, why waste your intelligence on just posting videos to your blog when you could be giving us something enlightening to read? 282132

Leave a Reply