Zenity create a scale dialog

by Daniel Pham
Published: Updated:
This entry is part 9 of 13 in the series GUI for bash script using Zenity

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
Zenity scale dialog with default options

Other options of scale

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

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

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://devopslite.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).

(This is an article from my old blog that has been inactive for a long time, I don’t want to throw it away so I will keep it and hope it helps someone).

0 0 votes
Article Rating
Series Navigation«« Previous part: Zenity create a form dialogNext part: Zenity create a list dialog »»

You may also like

Notify of
Inline Feedbacks
View all comments

DevOps Lite is a personal blog specializing in technology with main topics about DevOps, DevSecOps, SRE and System Administrator. Articles are shared for free and contributed to the community.



Subscribe my Newsletter for new blog posts. Stay updated from your inbox!

© 2021-2024 DevOpsLite.com – All rights reserved.

Please write sources “DevOpsLite.com” when using articles from this website.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

Would love your thoughts, please comment.x

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.