Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[WIP] Deprecate gtk, gdk and wx backends and remove Cocoaagg #6574

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

jenshnielsen
Copy link
Member

I still need to add an api_change note and update the documentation to reflect the deprecation.

The inheritance between the various Gtk backends is a bit complicated but this solution correctly prints the deprecation warning when using the Gtk and Gdk backends but not the GtkAgg og GtkCairo backends.

I also removed some references to the long since removed fltk and emf backends

Fixes #6541

warn_deprecated('2.0', message="The GDK backend is "
"deprecated. It is untested, known to be "
"broken and will be removed in Matplotlib 2.2. "
"Use the Agg backend instead.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need this line; the replacement advice is auto-generated when you supply the alternative kwarg.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought so too but I don't see it without explicitly adding the last line.

This is the warning message from the above as it looks for me

/usr/local/lib/python2.7/site-packages/matplotlib/cbook.py:137: MatplotlibDeprecationWarning: The GTK backend is deprecated. It is untested, known to be broken and will be removed in Matplotlib 2.2. Use the GTKAgg backend instead.
  warnings.warn(message, mplDeprecation, stacklevel=1)

@tacaswell tacaswell modified the milestones: 2.1 (next point release), 2.0 (style change major release) Jun 12, 2016
@tacaswell
Copy link
Member

@OceanWolf @fariza Can you take a look at this verify that this does not warn on the supported versions of gtk* backends?

@OceanWolf
Copy link
Member

Yay for getting rid of a MacO$ backend that I can't test the backend refactor on! But why don't we deprecate CocoaAgg on the same timeline as the other two rather than immediately removing it now?

I didn't realise that GTK existed as a separate backend from GTKAgg and GTKCairo, I always assumed that GTK aliased to GTKAgg or`GTKCairo``.

P.S. Never heard of FLTK until now ;).

@efiring
Copy link
Member

efiring commented Jun 13, 2016

On 2016/06/13 10:33 AM, OceanWolf wrote:

But why don't we deprecate |CocoaAgg| on the same timeline as the other
two rather than immediately removing it now?

It was never a complete backend, and has been deprecated since 1.3 with
removal scheduled in 1.4, but forgotten. It is highly unlikely that
anyone is using it for anything.

@OceanWolf
Copy link
Member

Ahh, okay, then we have given users plenty of time to migrate away from it.

In terms of testing, I can't get the GTKAgg/Cairo backends to work on python3... a bug?

ImportError: Gtk* backend requires pygtk to be installed.`` I look in the debian

In debian we don't have a python-gtk2 only python3-gi.

@fariza do you still use python2, if not I will recompile mpl for python2.

@jenshnielsen
Copy link
Member Author

As far as I know PyGtk2 never supported python3 so the GTK2 backends are python 2 only

@fariza
Copy link
Member

fariza commented Jun 13, 2016

This was the case long time ago, I don't know still the same but I have always thought
Python2 => GTK2
Python3 => GTK3

@OceanWolf
Copy link
Member

Not 100% sure about that...

import gi
gi.require_version("Gtk", "2.0")
from gi.repository import Gtk as gtk, Gdk as gdk, GObject as gobject, GLib, Pango as pango

gives

/usr/lib/python3/dist-packages/gi/overrides/Gtk.py:50: RuntimeWarning: You have imported the Gtk 2.0 module.  Because Gtk 2.0 was not designed for use with introspection some of the interfaces and API will fail.  As such this is not supported by the pygobject development team and we encourage you to port your app to Gtk 3 or greater. PyGTK is the recomended python module to use with Gtk 2.0

I can't test further as I don't think _backend_gdk.so builds under python3.

@OceanWolf
Copy link
Member

OceanWolf commented Jun 13, 2016

Btw, if you want to make it really clear and extra safe you can write:

if self.__class__ == FigureCanvasGTK:
  warn.deprecated()

I have tested this syntax on both python2.7 and python3.5.1 in __init__ and both do the expected thing, with self.__class__ referring to the actual class of the instance.

class Parent(object):
    def __init__(self):
        print('Setting up Parent', self.__class__)
        if self.__class__ == Parent:
            print('I am me')
        else:
            print('I am someone else')

class Child(Parent):
    def __init__(self):
        print('Setting up Child', self.__class__)
        super(Child, self).__init__()


print('--- Creating Parent ---')
a = Parent()

print('--- Creating Child ---')
b = Child()

@tacaswell
Copy link
Member

Suspect this was broken by the six merge

@jenshnielsen
Copy link
Member Author

Closing in favour of #6582

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants