Table of Contents
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 --scaleThe 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.

Other options of scale
When you use –scale, there are some other options used as the table below.
| Option | Meaning |
--text=TEXT | Set the dialog text. (Default like image above: Adjust the scale value). You can add any text that you want. |
--value=VALUE | Set 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=VALUE | Set minimum value. (Default: 0). You can change it to any number you want. |
--max-value=VALUE | Set maximum value. (Default: 100). Similar to --min-value, you can set any number. |
--step=VALUE | Set 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-partial | Print 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. |

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
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 more: Create a progress dialog.
You copy the script below and change the information as you like.
#!/bin/bash
# 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.";;
esac
}
# Main function
f_main () {
f_create_scale
}
f_main
exitConclusion
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).