24、dialog学习笔记

每个对话框提供的输出有两种形式:                      

   1.  将所有输出到stderr 输出,不显示到屏幕。        

   2.  使用退出状态码,“OK”为0,“NO”为1,"ESC"为255用法

用法:

dialog 通用选项 窗体选项


常用通用选项

  [--backtitle <backtitle>]    指定背景标题

  [--begin <y> <x>]             指定窗体左上角的起始位置

  [--cancel-label <str>]        指定cancel按键显示的内容

  [--colors]                            指定文本内容颜色\Znum显示的文本\Zn,num取值范围1-7

  [--default-item <str>]        指定menu窗体中默认选中的条目,默认为第一条

  [--defaultno]                      指定yesno窗体中默认选中的为no

  [--exit-label <str>]             指定exit按键显示的内容

  [--extra-button]                  添加额外按键

  [--extra-label <str>]           额外按键显示的内容

  [--insecure]                         指定passwordbox窗体中,密码以*格式显示

  [--no-cancel]                      取消cancel按键

  [--no-label <str>]              指定no按键显示的内容

  [--no-ok]                            取消ok按键

  [--no-shadow]                   取消阴影

  [--nook]                             取消ok按键

  [--ok-label <str>]              指定ok按键显示的内容

  [--shadow]                         显示阴影

  [--sleep <secs>]                指定窗体休眠时间,这段时间内无法做其他操作

  [--stderr]                            指定输出到标准错误输出

  [--stdout]                           指定输出到标准输出,可以使用命令替换来获取dialog输出结果

  [--timeout <secs>]            指定无操作是自动退出窗体

  [--title <title>]                   指定窗体标题

  

窗体

  --calendar     <text> <height> <width> <day> <month> <year>

  --checklist    <text> <height> <width> <list height> <tag1> <item1> <status1>...

  --dselect      <directory> <height> <width>

  --editbox      <file> <height> <width>

  --form         <text> <height> <width> <form height> <label1> <l_y1> <l_x1> <item1> <i_y1> <i_x1> <flen1> <ilen1>...

  --fselect      <filepath> <height> <width>

  --gauge        <text> <height> <width> [<percent>]

  --infobox      <text> <height> <width>

  --inputbox     <text> <height> <width> [<init>]

  --inputmenu    <text> <height> <width> <menu height> <tag1> <item1>...

  --menu         <text> <height> <width> <menu height> <tag1> <item1>...

  --mixedform    <text> <height> <width> <form height> <label1> <l_y1> <l_x1> <item1> <i_y1> <i_x1> <flen1> <ilen1> <itype>...

  --mixedgauge   <text> <height> <width> <percent> <tag1> <item1>...

  --msgbox       <text> <height> <width>

  --passwordbox  <text> <height> <width> [<init>]

  --passwordform <text> <height> <width> <form height> <label1> <l_y1> <l_x1> <item1> <i_y1> <i_x1> <flen1> <ilen1>...

  --pause        <text> <height> <width> <seconds>

  --progressbox  <height> <width>

  --radiolist    <text> <height> <width> <list height> <tag1> <item1> <status1>...

  --tailbox      <file> <height> <width>

  --tailboxbg    <file> <height> <width>

  --textbox      <file> <height> <width>

  --timebox      <text> <height> <width> <hour> <minute> <second>

  --yesno        <text> <height> <width>


应用实例:

日历窗体  

echo `dialog --stdout --title 日历窗体 --calendar 显示日期 10 30 8 8 2008`


复选窗体

echo `dialog --stdout --title 复选窗体 --checklist 选择以下选项 10 30 5 Disk "Disk Info" 1 Mem "Memory Info" 2`


目录选择窗体

echo `dialog --stdout --title 目录选择窗体 --dselect /root 10 30`


文本编辑窗体

dialog --stdout --title 文本编辑窗体 --editbox /home/inittab 100 300 > /home/inittab_edit


表单窗体

echo `dialog --stdout --title  --form 表单 20 50 10 username: 1 1 "" 1 10 20 20 password: 2 1 "" 2 10 20 20 userid: 3 3 "" 3 10 20 20`


文件选择窗体

echo `dialog --stdout --title 文件选择窗体 --fselect /etc/sysconfig/network-scripts/ 20 50`


进度条窗体

for I in {1..100};do echo $I; sleep 0.1; done | dialog --title 进度条窗体 --gauge 进度 10 50 0

for I in {1..100};do echo $I; echo XXX; echo 完成进度:$I%;echo XXX; sleep 0.1; done | dialog --title 进度条窗体 --gauge 进度 10 50 0


信息显示窗体

dialog --title 信息显示窗体 --infobox 此窗体和msgbox窗体类似,用于显示信息 10 20


输入窗体

echo `dialog --stdout --title 输入窗体 --inputbox username 10 30 123`


菜单窗体

echo `dialog --stdout --title 菜单窗体  --menu 选择任意选项  20 50 10 Disk "Disk Info" Mem "Memory Info"`


信息显示窗体

dialog --title 信息显示窗体 --msgbox 此窗体和infobox窗体类似,用于显示信息 10 20


密码输入窗体

echo `dialog --stdout --title 密码输入窗体 --passwordbox 请输入密码 20 50`


密码输入菜单窗体

echo `dialog --title 密码输入菜单窗体 --stdout --passwordform 请输入密码 20 50 10 张三: 1 1 '' 1 10 10 10 李四: 2 1 '' 2 10 10 10`


倒计时窗体

dialog --title 倒计时窗体 --pause 倒计时 10 20 10


文本显示窗体

dialog --title 文本显示窗体 --textbox /etc/inittab 100 200


时间窗体

echo `dialog --title 时间窗体 --stdout --timebox 显示时间 20 50 1 1 1`


YES/NO窗体

dialog --title YES/NO窗体 --yesno 请选择YES或者NO 10 20


猜你喜欢

转载自blog.51cto.com/kaiyuandiantang/2306585