Zenity create a scale dialog

Share this post to your friends !

This entry is part 9 of 13 in the series GUI for bash script using Zenity

WriteBash - To create a dialog box in Zenity is quite simple. You only need to use the --scale option to have the dialog box appear. However, the full use of the --scale feature in Zenity like? Did you find out about it? In this article, I talk about how to create a scale dialog in Zenity.

Create a scale dialog

To create a scale dialog, use the following basic command:

zenity --scale

The default dialog will appear as shown in the image below. Really simple, just drag the mouse left or right to select the value. Then press the OK button to finish. The value (a number) will be returned on the command window.

zenity-create-a-scale-dialog-01 Zenity create a scale dialog
Zenity scale dialog with default options

Other options of scale

When you use –scale, there are some other options used as the table below.

Zenity scale options
--text=TEXTSet the dialog text. (Default like image above: Adjust the scale value). You can add any text that you want.
--value=VALUESet initial value. (Default: 0) You must specify value between minimum value to maximum value. For example, you want the dialog box with a fixed value of 50. You would use: --value=50
--min-value=VALUESet minimum value. (Default: 0). You can change it to any number you want.
--max-value=VALUESet maximum value. (Default: 100). Similar to --min-value, you can set any number.
--step=VALUESet step size. (Default: 1). This option will not make any difference when using the mouse to select a value. When you use the keyboard (left arrow or right arrow), this option will increase (or decrease) the value by the interval (by the value of --step).
--print-partialPrint value to standard output, whenever a value is changed. This option prints out the value of any change you choose. You can see the image below the table.
--hide-value Hide value on dialog. You look at the picture above will see the number 0 is on the right side of the scale bar. This option will hide this number from the dialog box.
zenity-create-a-scale-dialog-02 Zenity create a scale dialog
Zenity scale dialog with –print-partial option

Now try running the command with multiple options at once as below:

zenity --scale --text="WriteBash.com Zenity Scale Dialog" --value=20 --min-value=0 --max-value=90 --step=5

zenity-create-a-scale-dialog-03 Zenity create a scale dialog

Bash script to create scale dialog

Once you have finished exploring the options and using the command to create a scale dialog. Now you can use it in a specific script.

Read moreCreate a progress dialog.

You copy the script below and change the information as you like.

# Script author: Danie Pham
# Script site: https://www.writebash.com
# Script date: 27-01-2018
# Script use to create a scale dialog by using Zenity

# Function create a scale dialog
f_create_scale () {
    # Define command
    VALUE=`zenity --scale --text="WriteBash.com Zenity Scale Dialog" --value=20 --min-value=0 --max-value=90 --step=5`

    case $? in
        0) echo "You selected $VALUE.";;
        1) echo "No value selected.";;
        -1) echo "An unexpected error has occurred.";;

# Main function
f_main () {



With this article, you can create a simple dialog box. You can use it as a tool to select a percentage value (such as percentage transparency).

Continue reading the series«« Previous part: Zenity create a form dialogNext part: Zenity create a list dialog »»
If you liked this article, then please subscribe to our YouTube Channel for more video tutorials. You can also find us on Twitter and Facebook.

Share this post to your friends !
If you appreciate what we share in this blog, you can support us by:
  1. Stay connected to: Facebook | Twitter | Google Plus | YouTube
  2. Subscribe email to recieve new posts from us: Sign up now.
  3. Start your own blog with SSD VPS - Free Let's Encrypt SSL ($2.5/month).
  4. Become a Supporter - Make a contribution via PayPal.
  5. Support us by purchasing Ribbon Lite Child theme being using on this website.

We are thankful for your support.

single post bottom banner
«« »»

Got something to say? Join the discussion

Please keep in mind that all comments are subject to our Comment Policy. Your email address will not be published.
This site uses Akismet to reduce spam. Learn how your comment data is processed.