mike3996
mike3996

Reputation: 17517

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 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?

Upvotes: 1

Views: 3807

Answers (3)

James Danforth
James Danforth

Reputation: 827

using PySide6... had similar warning from Gtk when using QFileDialog static methods. (QFileDialog.getSaveFilename, etc)

when I built the object without using static method, the warning disappeared. (eg obj = QFileDialog(), obj.setFileMode(QFileDialog.FileMode.ExistingFile) ... )

Upvotes: 0

Steven Sproat
Steven Sproat

Reputation: 4578

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.

Upvotes: 1

Mike Driscoll
Mike Driscoll

Reputation: 33071

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.

Upvotes: 0

Related Questions