Moving text menus to the gui.

Take your standard menu and with a little help it can become gui friendly.

Original code:

#! /bin/bash

echo "************************"
echo "* Music programs       *"
echo "************************"
echo "* [1] Autoharp         *"
echo "* [2] Radio            *"
echo "*                      *"
echo "* [0] Exit/Stop        *"
echo "************************"
echo
echo "Enter your menu choice [1-2, or 0]: "
read -n 1 yourch
case $yourch in
1) autoharp.sh  ;;
2) radio.sh ;;
0) exit 0 ;;
*) echo "Oopps!!! Please select choice 1,2 or 0"
echo "Press Enter to continue. . ." ; read ;;
esac
done


Which generates:



Or you could go to a mouse friendly gui:


#! /bin/bash
while selection=$(zenity --list \
"1 Autoharp" \
"2 Radio" \
"0 Exit/stop" \
--column="" --text="Music programs" --title="Menu")
do
case "$selection" in
"1 Autoharp") autoharp.sh;;
"2 Radio") radio.sh;;
"0 Exit") exit;;
*)  zenity --error --text="Invalid option. Try another one.";;
esac
done

Which generates:





As simple as that.

Comments

Popular posts from this blog

Guiless?

Web.com and Network Solutions, the Walmart of the internet.

MSOffice vs Libreoffice