开发者

How to suppress Gtk-warnings from a wxWidgets/wxPython application?

The wxWidgets project uses GTK in Linux, and my wxPython-based application with basic components makes a lot of warnings an开发者_StackOverflow社区d errors for which I as a python coder/end user have not much to do about it.

The errors distract my standard streams and aren't fatal to my program. The usual ones in my case are:

(python2.6:9886): Gtk-WARNING **: gtk_widget_size_allocate(): attempt to allocate widget with width -4 and height 13
(python2.6:9886): Gtk-CRITICAL **: gtk_widget_is_ancestor: assertion `ancestor != NULL' failed

Is it so bad a practice to suppress this kind of third-party errors from my part? And how is this done?


It's not coming from wxPython -- it's from GTK itself. You can fix the first one by ensuring positive values (or -1 for "any") are used for the size values when creating Controls.

I'm not too sure on the second one - can you pinpoint what widget/event triggers it? I was having one error about printing and that was due to not having CUPS set up properly.


Just redirect stderr somewhere else.

import sys
sys.stderr = open("some path")

Or you could redirect to a class with a Write method that does nothing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜