简单的 Tcl/wish 错误对话框
我正在编写一个由家长愿望程序调用的 Perl 脚本。 (我无法更改调用的 Wish 程序。) Wish 程序从子脚本捕获 stdout,但忽略返回状态和 stderr。
因此,如果我的 Perl 脚本遇到错误,我想弹出一个包含错误消息的简单 GUI 对话框。所以我摆弄了一些愿望,得到了这个,它很接近:
echo 'tk_dialog .d "Error" "Something bad happened." error 0 "Close"; exit' | wish
但是愿望启动时创建的主窗口也会出现,并且坐在那里未使用且丑陋。我不知道如何隐藏、销毁或替换该主窗口。我还没有足够的愿望能够用单独的小部件在主窗口中轻松制作出如此漂亮的东西。
我怎样才能使用wish或任何其他可能安装在大多数带有X Windows的Unix机器上的工具来显示一个简单的GUI窗口?
I'm writing a Perl script to be invoked by a parent wish program. (I can't change the invoking wish program.) The wish program captures stdout from the child script, but ignores return status and stderr.
So if my Perl script hits an error, I want to pop up a simple GUI dialog containing the error message. So I fiddled around some with wish, and got this, which comes close:
echo 'tk_dialog .d "Error" "Something bad happened." error 0 "Close"; exit' | wish
But the main window created when wish starts also appears and sits there unused and ugly. I can't figure out how to hide, destroy, or replace that main window. And I don't know enough wish yet to easily make something so nice-looking in the main window with individual widgets.
How can I just get a simple GUI window to appear, using either wish or any other tool likely to be installed on most Unix boxes with X Windows?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过在脚本开头添加
wmwithdraw .
来隐藏主窗口:You can hide the main window by adding
wm withdraw .
at the start of your script: