dialog<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> 常見的對話框 --backtitle 「 「 背景文字 --title 「 「 定義文本框前的文字 --colors 給顯示字體添加顏色 --defaultno 定義默認值為no --stout 定義到標準輸出 --insecure 和—passwordbox 一起使用 讓輸入的密碼以*號顯示,默認為不顯示 --begin x y 定義對話框的顯示位置 下面介紹幾種常見的dialog對話框 1. --yesno 「 」 對話框高 對話框寬 顯示一個對話框,提示用戶選擇yes 或者no,默認選擇yes 選擇后使用echo $? 發現選擇默認為 0 相反為1 [[email protected] ~]# dialog --backtitle "for example" --title "hello" --yesno "doyou want copy this file" 8 20 背景文字為 for example 對話框頭部顯示 hello 提供yes no 供選擇 [[email protected] ~]# dialog --colors --backtitle "Z1for exampleZn" --title "hello" --yesno "Z2doyou want copy this fileZn" 8 20 為文字添加顏色,注意—colors的格式 在Z後面添加顏色數字,共有1到7種顏色,最后在文字最后以Zn結尾 [[email protected] ~]# dialog --defaultno --colors --backtitle "Z1for exampleZn" --title "hello" --yesno "Z2doyou want copy this fileZn" 8 20 使用—defaultno 更改默認值,使對話框出來時藍色游標在no選項上 但是注意,在更改完之後,使用echo $?查看結果是仍是1 [[email protected] ~]# dialog --begin 10 15 --defaultno --colors --backtitle "Z1for exampleZn" --title "hello" --yesno "Z2doyou want copy this fileZn" 8 20 --begin 是更改對話框的顯示位置的,我們可以使用begin讓它顯示在我們希望的位置 2. --inputbox ""對話框高 對話框寬 提供一個可輸入信息的對話框,可追加文件 dialog --colors --backtitle "Z1for exampleZn" --title "hello" --inputbox "please enter your name.." 12 20 nihao[[email protected] ~]# dialog --colors --backtitle "Z1for exampleZn" --title "hellonputbox "please enter your name.." 12 20 2>/root/text.txt 將輸入信息追加文件里,dialog默認為錯誤輸出 3.—msgbox 「 「 對話框高 對話框寬 顯示一個對話框,顯示一句話 [[email protected] ~]# dialog --colors --backtitle "Z1for exampleZn" --title "hello" --msgbox "OK" 8 15 4.—mauge 高 寬 使用管道符把前面的數字傳送到dialog 以百分數顯示傳輸過程,最后一位為百分比 [[email protected] ~]# (PERCENT=0;while [ $PERCENT -lt 100 ];do PERCENT=$[ $PERCENT 1] ;echo $PERCENT; done )|dialog --title "GAUGE WORKING" --gauge "working" 13 20 0 5. –menu 「 「 對話框高 對話框寬 菜單高 N1 「 「 N2 「 「 N3 「 「 [[email protected] ~]# dialog --backtitle "for example" --title "hello" --menu "please have a choice" 12 25 <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />7 a "cat /etc/passwd" b "cat /etc/group" c "cat /etc/shadow" 提供一個對話框,可以使用上下框選擇 6. –form 「 」對話框高 對話框寬 文本行數 「提示語「 行數 列數 「默認字」 輸入字元行數 字元列 可輸入字元數 0 (0 指是否限制輸入的字元,如果是2的話就是指只能輸入兩個字元) [[email protected] ~]# dialog --backtitle "for example" --title "hello" --form "input field" 15 28 3 "name:" 1 2 "natasha" 1 13 13 2 "school:" 2 2 "" 2 13 13 0 " address:" 3 2 "" 3 13 13 0 7 –passwordbox 「 」 高 寬 dialog --title "hello" --passwordbox "please" 12 20 密碼輸入框 加上—insecure 以** 顯示 dialog --title "hello" --insecure --passwordbox "please" 12 20 8. –fselect 「 」文件路徑 高 寬 顯示一個目錄中的文件及目錄,可以選擇 [[email protected] ~]# dialog --backtitle "for example" --title "hello" --fselect /etc/yum.repos.d 12 25 9.—textbox 文件路徑 高 寬 顯示一個文件內的內容 [[email protected] ~]# dialog --backtitle "for example" --title "hello" --textbox //etc/sysconfig/network 12 25
[火星人
]
dialog幾個常見的對話框已經有866次圍觀
http://coctec.com/docs/linux/show-post-51986.html