linux dialog中文,linux dialog详解(图形化shell)

100316184517.png

11.from框架(表单)

格式:dialog --form text height width formheight [ label y x item y x flen ilen ] ...

其中

flen 表示field length,定义了:选定字段中显示的长度

ilen 表示 input-length, 定义了:在外地输入的数据允许的长度

使用up/down(或ctrl/ N,ctrl/ P)在使用领域之间移动。使用tab键在窗口之间切换。

例子:

# dialog --title "Add a user" --form "Please input the infomation of new user:" 12 40 4

"Username:" 1  1 "" 1  15  15  0

"Full name:" 2  1 "" 2  15  15  0

"Home Dir:" 3  1 "" 3  15  15  0

"Shell:"    4   1 "" 4  15  15  0

6597814136028938272.jpg

综合应用示例:

#!/bin/bash

yesno() {

dialog --title "First screen" --backtitle "Test Program" --clear --yesno

"Start this test program or not ?

This decesion have to make by you. " 16 51

# yes is 0, no is 1 , esc is 255

result=$?

if [ $result -eq 1 ] ; then

exit 1;

elif [ $result -eq 255 ]; then

exit 255;

fi

username

}

username() {

cat /dev/null >/tmp/test.username

dialog --title "Second screen" --backtitle "Test Program" --clear --inputbox

"Please input your username (default: hello) " 16 51 "hello" 2>/tmp/test.username

result=$?

if [ $result -eq 1 ] ; then

yesno

elif [ $result -eq 255 ]; then

exit 255;

fi

password

}

password() {

cat /dev/null >/tmp/test.password

dialog --insecure --title "Third screen" --backtitle "Test Program" --clear --passwordbox

"Please input your password (default: 123456) " 16 51 "123456" 2>/tmp/test.password

result=$?

if [ $result -eq 1 ] ; then

username

elif [ $result -eq 255 ]; then

exit 255;

fi

occupation

}

occupation() {

cat /dev/null >/tmp/test.occupation

dialog --title "Forth screen" --backtitle "Test Program" --clear --menu

"Please choose your occupation: (default: IT)" 16 51 3

IT "The worst occupation"

CEO "The best occupation"

Teacher "Not the best or worst" 2>/tmp/test.occupation

result=$?

if [ $result -eq 1 ] ; then

password

elif [ $result -eq 255 ]; then

exit 255;

fi

finish

}

finish() {

dialog --title "Fifth screen" --backtitle "Test Program" --clear --msgbox

"Congratulations! The test program has finished!

Username: $(cat /tmp/test.username)

Password: $(cat /tmp/test.password)

Occupation: $(cat /tmp/test.occupation)" 16 51

result=$?

if [ $result -eq 1 ] ; then

occupation

elif [ $result -eq 255 ]; then

exit 255;

fi

}

yesno

6597807538959176392.jpg

6597825131145221498.jpg

6597968067656835422.jpg

6597307261168029398.jpg

6598240746540299472.jpg

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值