[Level 2] Shell Interactive With Zenity Episode 7 -- progress

Sometime we want to show a progress bar to let user know the process is still running or how many percentage of task has done. For this purpose, you can use an option "--progress" to fullfill your need.
Ths Synopsis as below:
SYNOPSIS
     zenity --progress [--title=title]  [--window-icon=path]  [--width=width]   [--height=height]   [--timeout=seconds]  [--text=text] [--percentage=number] [--pulsate]  [--auto-close] [--auto-kill]

Just like "--calendar", if you press "ESC" key or click button "Cancel", the return code will be "1". If you select one option and click "OK", zenity will response the option and return the code will be "0". And also the same effect about the options "--title", "--timeout"...etc, for saving your time, please refer to the previous post "[Level 2] Shell Interactive With Zenity Episode 1 -- calendar", too.



The first command that you can try is "zenity --progress".
# zenity --progress

You will show a pop screen as above, but it just an empty bar, why?
Because the zenity progress bar is waiting your information to display the progress. Try to key some values on the terminal. Like below:
# zenity --progress
10

30

50

100

You will find out, when the number is less than 100, the button "OK" is disabled, that means user just can press "Cancel" buttion. When you give the number 100, the button "OK" is enabled.

If you want to progress show at the specific percentage, you can use the option "--percentage"
# zenity --progress --percentage=30

In some case, your program cannot predict the "percentage" of total task, and you just want to show the user, "The program is still running". So you can use the option "--pulsate" to let the progress "block" moving around.
# zenity --progress --pulsate

But when the command you enter, there still nothing on progress bar. You should press any key on the terminal, then the "block" will show up.
 
 
 
 

Another way to use "--pulsate" like the command below:
# find / -print | zenity --progress --pulsate
The progess bar will rolling until find command is done.

The last two options are "--auto-close" and "--auto-kill".
"--auto-close" means, the progress bar will close automatically after the process is done. And "--auto-kill" means, when the user close the progress bar, will also kill the parent process.

Wish this helps.

regards,
Stanley Huang

Comments

Popular posts from this blog

[Level 2] Shell Interactive With Zenity Episode 5 -- list

[Level 2] iif in Python