Fourth basic front end with dialog/Xdialog - Radiolist and Checklist

Radiolists and checklists can be programmed just like menus. A simple radio list example is given below.
#! /bin/sh
DIALOG=${DIALOG=dialog}
tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$
trap "rm -f $tempfile" 0 1 2 5 15

$DIALOG --backtitle "Select your favorite singer" \
--title "My favorite singer" --clear \
--radiolist "Hi, you can select your favorite singer here " 20 61 5 \
"Rafi" "Mohammed Rafi" off \
"Lata" "Lata Mangeshkar" ON \
"Hemant" "Hemant Kumar" off \
"Dey" "MannaDey" off \
"Kishore" "Kishore Kumar" off \
"Yesudas" "K. J. Yesudas" off 2> $tempfile

retval=$?

choice=`cat $tempfile`
case $retval in
0)
echo "'$choice' is your favorite singer";;
1)
echo "Cancel pressed.";;
255)
echo "ESC pressed.";;
esac

A screen shot is shown below.

No comments:

Post a Comment