如何设置错误消息窗口大小?

时间:2018-02-23 04:08:45

标签: tcl tk

如何在弹出错误窗口中显示完整的消息?样品:enter image description here

error "convergency_check_start should be larger than 3."

1 个答案:

答案 0 :(得分:2)

如果您要增加错误窗口大小,则不会收到完整的错误消息。消息被故意截断。您可以查看Tk库文件夹中的bgerror.tcl,发现错误消息行被截断为45个字符。

您可以做的是覆盖::tk::dialog::error::bgerror程序。而且由于完全重写它太繁琐了,我建议修补它如下:

#!/usr/bin/wish

set eproc ::tk::dialog::error::bgerror
auto_load $eproc
proc $eproc [info args $eproc] [string map {45 150} [info body $eproc]]

after idle {
    error "Quick brown fox jumped over the lazy dog. Quick brown fox jumped over the lazy dog."
}

此代码在45正文中用150替换::tk::dialog::error::bgerror,并在窗口中显示整个错误消息。如果没有[string map ...],则只会显示大约一半的消息(在单击Details >>按钮后,您仍然可以看到所有带有堆栈跟踪的消息)。