Fifth basic front end with dialog/Xdialog - Building a Gauge

A gauge based on dialog can be used to indicate progress of your program. Building a gauge is slightly tricky. Look at the following example:

#!/bin/sh
DIALOG=${DIALOG=dialog}

COUNT=10
(
while test $COUNT != 110
do
echo $COUNT
echo "XXX"
echo "The new\n\message ($COUNT percent)"
echo "XXX"
COUNT=`expr $COUNT + 10`
sleep 1
done
) |
$DIALOG --title "My Gauge" --gauge "Hi, this is a gauge widget" 20 70 0

Here the dialog program gets its input from the code shown within the parentheses. This code emits the number to be used for gauge and the message to be shown. The message to be shown in the gauge box must be surrounded by echo "XXX". The screen-shot of a gauge is shown below.

No comments:

Post a Comment