ºìÁªLinuxÃÅ»§
Linux°ïÖú

Linux³ÌʽÉè¼ÆÈëÃÅ - Dialog

·¢²¼Ê±¼ä:2006-03-29 11:17:58À´Ô´:ºìÁª×÷Õß:[Hl.y]
dialogÊǸöshell scriptsÓõģ¬ÊÂʵÉϵ±ÄúÏÂÔØLinux Kernelʱ£¬ÀïÃæÓиöscripts/lxdialogĿ¼£¬ÆäʵÄǾÍÊÇdialogԭʼÂ룬ֻÊÇLinux kernelΪÁ˱ÜÃâÓëÔ­ÓÐdialogÏà³åÍ»£¬½«Ãû×ÖÐÞ¸ÄΪlxdialog¡£µ±ÄúʹÓÃ"make menuconfig"ʱ£¬±ãÊÇÔÚÓÃdialogÕâÌ×¹¤¾ß¡£ÁíÍ⣬SlackwareµÄ°²×°³Ìʽ£¬ÊÂʵÉÏÒ²ÊÇÓÃdialogÕâÌ×¹¤¾ßÀ´×ö½çÃæµÄ¡£

Äú¿ÉÒÔÀûÓÃshell scriptÀ´ºô½Ðdialog£¬Ò²¿ÉÒÔÀûÓÃperlÀ´ºô½ÐËü£¬ÓÃÒÔÌṩ½ÏÓÑÉƵÄʹÓÃÕß½çÃæ¡£

ÀûÓÃdialogÕâ¸ö¹¤¾ß£¬Äú¿ÉÒÔÔÚ²»ÐèҪд"¼èÉî"µÄncursesµÄ³ÌʽµÄ×´¿öÏ£¬Ê¹ÓÃShell Script£¬Íê³ÉºÜ¸´ÔӵIJÙ×÷½çÃ棬´ó´ó¼õÉÙ²úÆ·¿ª·¢Ê±¼ä¡£


Äú¿ÉÒÔÓÃ"man dialog"À´²éËüµÄʹÓ÷½·¨¡£ÕâÀï×öһЩdialogµÄʹÓü°Ê¾·¶¡£

dialog --clear

Õû¸öÓ©Ä»»áÇå³ýááÀ뿪

dialog --create-rc file

dialogÖ§Ô®¶¯Ì¬¹æ»®£¬Õâ¸ö¹¦ÄÜ»á²úÉúÒ»¸öÑù±¾¡£

dialog [ --title title ] [ --backtitle backtitle ]
[--clear ] [ --separate-output ] box-options

--title title

¶Ô»°ºÐÉϵıêÌâÎÄ×Ö

--backtitle backtitle

×ÀÃæ±³¾°µÄ±êÌâ

box-options

dialogÄ¿Ç°ÌṩÁËyes/no box, menu box, input box, message box, text
box, info box, checklist box, radiolist box, ¼°gauge box¹²¾ÅÖÖwidget.

Exit Status

Èç¹û°´ÏÂYes»òOK°´¼ü£¬Ôò»á·µ»Ø0¡£No»òCancel»á·µ»Ø1¡£Èç¹û°´ÏÂESC»ò·¢Éú´íÎó£¬Ôò»á·µ»Ø-1¡£

--yesno text height width

[foxman@foxman /]# dialog --title "hello" --backtitle "Dialog"
--yesno "Is everything okay" 20 60


--msgbox text height width

[foxman@foxman /]# dialog --title "hello" --backtitle "Dialog"
--msgbox "Is everything okay" 20 60


--infobox text height width

[foxman@foxman dialog]# dialog --title "hey" --backtitle "Dialog"
--infobox "Is everything okay?" 10 60

Infobox»áÔÚÏÔʾѶϢááÁ¢¼´À뿪£¬ÔÚconsoleµÄ×´¿öÏ£¬Ñ¶Ï¢»áÁôÏ£¬µ«ÔÚX
TerminalÏ£¬ÓÉì¶X Terminal»áÁ¢¼´½«Ñ¶Ï¢Çå³ý£¬Screen Shot×¥²»µ½£¬Òò´ËÕâ
ÀïûÓÐScreenShot¡£Äú¿ÉÒÔÔÚconsoleϲâÊÔ¡£

--inputbox text height width [init]

[foxman@foxman dialog]# dialog --title "hey" --backtitle "Dialog"
--inputbox "Is everything okay?" 10 60 "yes"




--textbox file height width

[foxman@foxman copyright]# dialog --title "Array 30" --backtitle "All
For Chinese" --textbox array30 20 75


textboxºÜÏñÊǸö¼òµ¥µÄtext viewer£¬Ëü»áÏÔʾµµ°¸ÖеÄÎÄ×Ö¡£

--menu text height width menu-height [ tag item ] ...

[foxman@foxman dialog]# dialog --title "Menu Example" --menu "MENU"
20 60 4 tag1 " item1" tag2 "item2" tag3 "item3" tag4 "item4"




--checklist text height width list-height [ tag item status ]
...

[foxman@foxman dialog]# dialog --title "CheckList Example"
--checklist "Check List" 20 60 4 tag1 "item1" on tag2 "item2" off
tag3 "item3" on tag4 "item4" off


--radiolist text height width list-height [ tag item status
] ...

[foxman@foxman dialog]# dialog --title "RadioList Example"
--radiolist "Radio List" 20 60 4 tag1 "item1" on tag2 "item2" off
tag3 "item3" on tag4 "item4" off


--gauge text height width percent

[foxman@foxman dialog]# dialog --title "Installation" --backtitle
"Star Linux" --gauge "Linux Kernel" 10 60 50


gauge widgetÔÚÆô¶¯áᣬ»á´Óstdin¶ÁÈ¡percent½øÀ´£¬¶Áµ½EOFʱ½áÊø¡£


ÅäºÏShell Script½ø½×ʹÓÃ

µ¥µ¥ÖªµÀÿ¸ö¹¦ÄÜÈçºÎʹÓÃÊÇ»¹²»¹»µÄ£¬Ò»°ãÄúÒªÐèÒªÖªµÀÈçºÎÅäºÏScriptÀ´Ê¹Óá£
»áÐèÒª»¥¶¯µÄÓÐyesno¡¢inputbox¡¢menu¡¢checklist¡¢radiolist¡¢gauge¡£

yesno

·¶Àý
#!/bin/sh

DIALOG=dialog

if  $DIALOG --title "WCW v.s. NWO" --backtitle "Wrestling"\
--yesno "Are you ready to rumble?" 5 60; then
echo "Yeahhhhh"
else
echo "Nap..."
fi

inputbox

·¶Àý
#!/bin/sh

DIALOG=dialog

if  $DIALOG --title "The future is here" \
--inputbox "Where do you want to go tomorrow?" \
10 75 "Penguin" 2>my_own_destiny
then
way=`cat my_own_destiny`
echo "My way is  $way"
else
echo "freak out"
fi

menu

#!/bin/sh

if dialog --title "title" \
--menu "MENU" 20 60 14 \
tag1 "item1" tag2 "item2" 2>select
then
selection=`cat select`
echo "my selection is  $selection"
else
echo "go"
fi

checklist

#!/bin/sh

if dialog --title "title" \
--checklist "checklist" 20 60 14 \
tag1 "item1" on tag2 "item2" off 2>select
then
selections=`cat select`

echo "My selections are:"
for i in  $selections ; do
echo  $i
done

else
echo "go"
fi

radiolist

#!/bin/sh

if dialog --title "title" \
--radiolist "checklist" 20 60 14 \
tag1 "item1" on tag2 "item2" off 2>select
then
selection=`cat select`
echo "My selection is  $selection"
else
echo "go"
fi

gauge

µ½Ä¿Ç°ÎªÖ¹£¬gaugeËƺõ¶¼Ò»Ö±ÓеãÎÊÌ⣬ÎļþÉÏҲд˵ÊÇÓеãÎÊÌ⣬Ëù¸½µÄ·¶Àý³ÌʽҲÊÇÎÞ·¨Ê¹Ó㬲»½¨ÒéÄúʹÓÃ(ÎÒ×Ô¼ºÒ²Íæ²»³öÀ´£¬ÄãÈç¹ûÓÐÊÔ³öÀ´£¬ÇëÀ´ÐŸæËßÎÒ)¡£


OK STATION, Webmaster, Brian Lin
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 0 ÌõÆÀÂÛ