matplotlib window icon

Hello, I'm developing a plugin in pygtk, which

    > indirectly (via networkx) uses matplotlib to display
    > graphs.

    > Now, I have the following problem: When I import pylab,
    > my window icon (the small icon in the window decoration)
    > gets replaced by the matplotlib icon. I pasted a sample
    > script below to illustrate.

    > This is amazingly annoying for me since I am merely
    > writing a plugin for an existing application and cannot
    > simply replace the original window icon.

    > Is there any way to supress this behaviour?

You can comment out the code in backends/

    gtk.window_set_default_icon_from_file (
        os.path.join (matplotlib.rcParams['datapath'], 'matplotlib.svg'))
except:'Could not load matplotlib icon: %s' % sys.exc_info()[1])

or physically remove the icon in which case you'll just get a report
that it is missing.

You can also set the icon yourself after import matplotlib/backend_gtk
using the same code.

Well, this seems like a bug to me, then. Matplotlib offers the
possibility to draw to a file instead of opening a window. In this case,
the default window icon should *not* get overridden.

The best way to patch this would be to set the default window icon only
when the gtk main loop is entered.

I attached a patch against the current SVN. It simply moves the window
icon declaration just before the line where gtk.main() gets called.

Should I file a bug somewhere? Or does the patch reach the devs here?

Thanks in advance,
Fred (766 Bytes)


On Thu, 2006-05-18 at 15:57 -0500, John Hunter wrote:

You can comment out the code in backends/