Learn More →
Learn More →
sudo apt install bpytop
q
dialog --title <title> --msgbox <text> <height> <width>
dialog --title "Hi Mango" --msgbox "2024/02/27 Linux TUI課程,這是我第一個Dialog專案,就是簡單顯示GUI畫面,今天(27日)仍受強烈大陸冷氣團影響,天氣寒冷,氣溫12-16度,請
務必多添衣保暖;有局部短暫雨,出門請攜帶雨具備用。" 10 50
Learn More →
dialog --title "訊息視窗" --msgbox "Hello Mango\nIt's a messagebox.\nHave a nice day." 10 50
Learn More →
--calendar <text> <height> <width> <day> <month> <year>
dialog --calendar "請選擇一個日期:" 4 50 27 2 2024
Learn More →
dialog --title "資訊輸入框" --inputbox "你的名字:" 10 50
Learn More →
dialog --title "請輸入密碼" --passwordbox "你的密碼:" 10 50
Learn More →
dialog --title "是非題" --yesno "人生的樂趣在於不可預期,同意?" 10 50
Learn More →
# 文檔視窗,顯示文檔內容
--textbox <file> <height> <width>
dialog --title "文字檔內容呈現" --textbox ~/theword.txt 10 50
Learn More →
dialog --title "選單模式" --menu "可上下選擇" 10 50 3 1 "我可以" 2 "我想要" 3 "我不要"
Learn More →
# 表單,可以依照表格輸入
--form <text> <height> <width> <form height> <label1> <l_y1> <l_x1> <item1> <i_y1> <i_x1> <flen1> <ilen1>...
dialog --title "表單模式" --form "表單範例" 10 50 3 "Username:" 1 1 "" 1 15 25 0 "Age:" 2 1 "" 2 15 25 0 "Department:" 3 1 "" 3 15 25 0
dialog --title "表單模式" --form "表單範例" 10 50 3 \
"Username:" 1 1 "" 1 15 25 0 \
"Age:" 2 1 "" 2 15 25 0 \
"Department:" 3 1 "" 3 15 25 0
Learn More →
# 選項清單,選項可以進行複選
--checklist <text> <height> <width> <list height> <tag1> <item1> <status1>...
dialog --title "表單模式" --checklist "表單範例(可複選)" 10 50 2 1 "今天天氣好" on 2 "今天心情好" off
dialog --title "表單模式" --checklist "表單範例(可複選)" 10 50 2 \
1 "今天天氣好" on \
2 "今天心情好" off
Learn More →
# 單選選單,只能單選一個選項
--radiolist <text> <height> <width> <list height> <tag1> <item1> <status1>...
dialog --title "生理性別" --radiolist "單選" 10 30 2 1 "男生" on 2 "女生" off
Learn More →
dialog --title "表單模式" --editbox theword.txt 30 50
Learn More →
# 進度條,顯示進度資訊
--gauge <text> <height> <width> [<percent>]
dialog --title "進度條" --gauge 目前進度 10 30 15
Learn More →
vim inputbox.sh
dialog --inputbox 請輸入文字 8 40 2> dialog-output;
text=`cat dialog-output`;
echo You input "$text".;
text=`dialog --stdout --inputbox "請輸入文字" 8 40`;
echo You input "$text".;
vim iinputbox2msgbox.sh
text=`dialog --stdout --inputbox "請輸入文字" 8 40`;
dialog --title "你輸入的文字" --msgbox "$text" 8 40;
vim pingip.sh
pingip=`dialog --stdout --inputbox "請輸入IP或網域名稱" 8 40`;
dialog --title "你輸入IP或網域" --msgbox "$pingip" 8 40;
ping $pingip -c 1 > pingip.txt;
dialog --title "PING結果" --textbox pingip.txt 10 100;
yesno.sh
dialog --yesno "是否繼續" 5 40
if [ $? -eq 0 ]; then
echo "確定"
else
echo "取消"
fi
[ $? -eq 0 ]
按 Unix shell script 慣例,0 表示正常、肯定等正面意義。 非零值(通常是1)皆表示錯誤、否定等錯誤意義。fi
shell script語法 -(倒者寫) 結束if
的語法pingtest.sh
--radiolist <text> <height> <width> <list height> <tag1> <item1> <status1>...
dialog --stdout --title "選擇PING測試" --radiolist "單選" 10 30 2 1 "ping 8.8.8.8" on 2 "ping ntc.im" off 1> pingtest.txt
pingtest=$(cat pingtest.txt)
case $pingtest in
1)
ping 8.8.8.8 -c 1
;;
2)
ping ntc.im -c 1
;;
*)
echo "?"
;;
esac
vim form.sh
#--form <text> <height> <width> <form height> <label1> <l_y1> <l_x1> <item1> <i_y1> <i_x1> <flen1> <ilen1>...
# <label1> 之後 為顯示名稱 選單號 輸入起始 "預設內容" 欄位起始 欄位高 欄位寬 可輸入字數(0為不限制)
dialog --stdout --title "表單模式" --form "個人資訊輸入" 10 50 3 "Username:" 1 1 "" 1 15 25 0 "Age:" 2 1 "" 2 15 25 0 "Department:" 3 1 "" 3 15 25 0 > form.txt
line1=$(cat form.txt | sed -n "1p")
line2=$(cat form.txt | sed -n "2p")
line3=$(cat form.txt | sed -n "3p")
dialog --title "你的個人資訊" --msgbox "你的名字是$line1 \n你今年$line2歲 \n你的部門是$line3 " 10 50
驗收時間:2024/3/4 AM
驗收班級:DV106
組隊方式:可同時個人及團隊編組
主題選擇:不限制(必須用到五種以上dialog形式進行互動)
建議主題:LAMP安裝與反安裝、ELK安裝與反安裝、Mariadb管理…等
交付方式:hackmd (參考 dialog專案示範
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up