Q:

Capture GTk warnings with normal logger module.

I have a wxPython application which when runs spews a GTK critical warning on stderr:
(raiju:27221): Gtk-CRITICAL **: IA__gtk_widget_set_size_request: assertion 'width >= -1' failed 

From reading around it, it seems that this warning is safe to ignore. I would like to log it nonetheless using Python's normal logging module.
How can I do that?
Note that I am using Phoenix and Python 3.

A:

I think you will need to build wxPython yourself with debugging turned off. I asked Robin Dunn, creator of wxPython about it and he said that there may be an environment variable you can set to suppress the output on the GTK side, but he didn't know what it was off-hand. 
These messages are going to the C runtime's stderr handle, not Python's, so you cannot redirect them using Python's sys.stderr.
I tried looking into a way to close the file handle or duplicate it, but I wasn't able to find anything cross-platform.

