views:

44

answers:

2

The wxWidgets project uses GTK in Linux, and my wxPython-based application with basic components makes a lot of warnings and 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?

A: 

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.

Mike Driscoll
It doesn't do the job. I tried redirecting before `wx.App` and I tried redirecting in my `wx.Frame`'s `__init__` to no avail.
progo
Hmmm...must be getting redirected in the C++ portion of wx, not the Python portion. Try dropping a line to the official wxPython mailing list. They'll have ideas.
Mike Driscoll
A: 

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.

Steven Sproat
The second error spams twice every time I switch tabs in wx.Notebook. But there are other cases as well. I appreciate your knowledge of GTK workings but I'm not sure whether I want to go on pleasing the GTK gods instead of focusing on the python
progo
Well the fact you're creating a control with a width of -4 shows that you're doing *something* wrong ;). Ah...notebooks - are you sure that your notebook's children have their parents set correctly? You can't supress them - for example, opening Nautilus from the command line often shows GTK warnings - but they're not generated from the program, per say.
Steven Sproat