对话框的主要类型:
复选框 --checklist 允许用户显示一个选项列表,每个选项都可以被单独选择
信息框 --infobox 在显示信息后,对话框立刻返回,但不清楚屏幕
输入框 --inputbox 允许用户输入文本
菜单框 --menu 允许用户选择列表中的一项
消息框 --msgbox 向用户显示一条信息,同时显示一个OK按钮,用户可以选择该按钮继续操作
单选框 --radiolist 允许用户选择列表中的一个选项
文本框 --textbox 允许用户在带有滚动条的文本框中显示一个文件的内容
是否框 --yesno 允许用户提问,用户可以选择yes 或no
#/bin/bash
#ASk some questions and colletc the answerdialog --title "Questionaire" --msgbox "Welcome to my sample survey" 9 36
dialog --title "Confirm" --yesno "Are you willing to take part?" 9 36
if [ $? != 0 ];then
dialog --infobox "Thanks you anyway" 5 20
sleep 2
dialog --clear
exit 0
fi
dialog --title "Questionnaire" --inputbox "Please enter your name" 9 30 2>_1.txt
Q_NAME=$(cat _1.txt)
dialog --menu "Q_NAME,what music do you like best?" 15 36 4 1 "Classical" 2 "Jzzz" 3 "Country" 4 "Others" 2>_1.txt
Q_MUSIC=$(cat _1.txt)
if [ "$Q_MUSIC" = "1" ] ;then
dialog --title "Likes Classical" --msgbox "Good choice" 12 25
else
dialog --title "Don't like Classical " --msgbox "shame" 12 25
fi
sleep 2
dialog --clear
exit 0