chm*_*mac 143
如果您使用Ubuntu许多发行版,该notify-send命令将在右上角抛出其中一个漂亮的易腐通知.像这样:
notify-send "My name is bash and I rock da house"
美丽!
Sté*_*hon 73
每个人都提到了禅宗,似乎还有很多其他人.一个混乱但有趣的列表在http://alternativeto.net/software/zenity/
首先,以文本格式标记,窗口标题,按钮标签为特色的zenity示例.
zenity \
--info \
--text="<span size=\"xx-large\">Time is $(date +%Hh%M).</span>\n\nGet your <b>coffee</b>." \
--title="Coffee time" \
--ok-label="Sip"
Run Code Online (Sandbox Code Playgroud)
gxmessage "my text"
Run Code Online (Sandbox Code Playgroud)
xmessage是非常老的所以它是稳定的,并且可能在所有使用X的发行版中都可用(因为它与X一起发布).它可以通过X资源进行自定义,对于那些已经使用Linux或Unix足够长的时间来了解它的意义(.Xdefaults任何人?).
xmessage -buttons Ok:0,"Not sure":1,Cancel:2 -default Ok -nearmouse "Is xmessage enough for the job ?" -timeout 10
Run Code Online (Sandbox Code Playgroud)
(未测试)
YAD:Zenity On Steroids [显示Shell脚本的图形对话] ~Web Upd8:Ubuntu/Linux博客.似乎没有自动调整对话框大小.
echo My text | yad \
--text-info \
--width=400 \
--height=200
Run Code Online (Sandbox Code Playgroud)
一个更大的例子
yad \
--title="Desktop entry editor" \
--text="Simple desktop entry editor" \
--form \
--field="Type:CB" \
--field="Name" \
--field="Generic name" \
--field="Comment" \
--field="Command:FL" \
--field="Icon" \
--field="In terminal:CHK" \
--field="Startup notify:CHK" "Application" "Name" "Generic name" "This is the comment" "/usr/bin/yad" "yad" FALSE TRUE \
--button="WebUpd8:2" \
--button="gtk-ok:0" \
--button="gtk-cancel:1"
Run Code Online (Sandbox Code Playgroud)
whiptail --msgbox "my text" 10 20
dialog --msgbox "my text" 10 20
Run Code Online (Sandbox Code Playgroud)
随意编辑.
Jim*_*Jim 46
该zenity应用程序似乎是你在找什么.
要从zenity获取输入,您可以指定一个变量并将zenity --entry的输出保存到它.它看起来像这样:
my_variable=$(zenity --entry)
Run Code Online (Sandbox Code Playgroud)
如果你现在查看my_variable中的值,它将是zenity弹出输入对话框中输入的内容.
如果要提示某些用户(或您)应该在对话框中输入的内容,请添加带有所需标签的--text开关.它看起来像这样:
my_variable=$(zenity --entry --text="What's my variable:")
Run Code Online (Sandbox Code Playgroud)
Zenity有很多其他适合特定任务的好选项,所以你可能想用zenity检查那些 - help.一个例子是--calendar选项,让您从图形日历中选择日期.
my_date=$(zenity --calendar)
Run Code Online (Sandbox Code Playgroud)
根据用户点击的内容,它提供了格式良好的日期:
echo ${my_date}
Run Code Online (Sandbox Code Playgroud)
得到:
08/05/2009
滑块选择器,错误,列表等也有选项.
希望这可以帮助.
如果没有其他东西。您可以启动一个 xterm 并在其中回显,如下所示:
xterm -e bash -c 'echo "this is the message";echo;echo -n "press enter to continue "; stty sane -echo;answer=$( while ! head -c 1;do true ;done);'
Run Code Online (Sandbox Code Playgroud)
这是一个小Tcl脚本,可以做你想要的.应该在Ubuntu上默认安装Wish解释器.
#!/usr/bin/wish
pack [label .msg -text [lindex $argv 0]]
pack [entry .ent]
bind .ent <KeyPress-Return> { puts [.ent get]; destroy . }
focus .ent
Run Code Online (Sandbox Code Playgroud)
像这样称呼它:
myanswer=`gui-prompt "type your answer and press enter"`
Run Code Online (Sandbox Code Playgroud)
小智 7
alert而notify-send似乎是同样的事情.我notify-send用于非输入消息,因为它没有窃取焦点,我找不到一种方法来阻止zenity等这样做.
例如
# This will display message and then disappear after a delay:
notify-send "job complete"
# This will display message and stay on-screen until clicked:
notify-send -u critical "job complete"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
152212 次 |
| 最近记录: |