摘要:Xdialog(dialog)
If you don't know what's the Xdialog(dialog), you can just copy the following lines to your terminal: what you can see??
bash
Xdialog --yesno "Do you want to learn more about Xdialog?" 0 0;case $? in
0)
echo "Result: Yes chosen.";;
1)
echo "Result: No chosen.";;
255)
echo "ESC pressed.";;
esac
Xdialog and dialog are very easy to use but of course not as powerful as a real graphical application. They fill the gap between a pure ASCII shell script and a full graphical application.
Xdialog and dialog come with a directoy called "samples" where you can find more examples (Redhat 7.3 stores them under /usr/share/doc/Xdialog-2.0.5/samples). Be careful however as some of them really do something and are not pure demo applications.
Xdialog and dialog offer a number of different dialog boxes. Not all of them are always appropriate for all types of shell scripts
The above was a pretty useless example of dialog/Xdialog but it shows how easy it is to program a simple graphical dialog. There are more interesting dialog boxes. Boxes like calendar, menus, filemanager, progess bar, text input, message box, password dialog, ... You can run
dialog --help
or
Xdialog --help
to get a list of the available dialog boxes. Xdialog has a few more boxes than dialog.
References:
http://www.chez.com/godefroy/
http://fr.linuxfocus.org/English/November2002/article267.shtml
small examples: GUI tar
http://fr.linuxfocus.org/common/src/article267/mktgz.txt