diff --git a/doc/api/api_changes/2016-06-deprecate_backends.rst b/doc/api/api_changes/2016-06-deprecate_backends.rst new file mode 100644 index 000000000000..7645f1fad615 --- /dev/null +++ b/doc/api/api_changes/2016-06-deprecate_backends.rst @@ -0,0 +1,20 @@ +GTK and GDK backends deprecated +``````````````````````````````` +The untested and broken GDK and GTK backends have been deprecated. +These backends allows figures to be rendered via the GDK api to +files and GTK2 figures. They are untested, known to be broken and +use have been discouraged for some time. The `GTKAgg` and `GTKCairo` backends +provide better and more tested ways of rendering figures to GTK2 windows. + +WX backend deprecated +````````````````````` +The untested WX backend has been deprecated. +This backend allows figures to be rendered via the WX api to +files and Wx figures. It is untested, and +use have been discouraged for some time. The `WXAgg` backend +provides a better and more tested way of rendering figures to WX windows. + +CocoaAgg backend removed +```````````````````````` + +The deprecated and not fully functional CocoaAgg backend has been removed diff --git a/doc/faq/usage_faq.rst b/doc/faq/usage_faq.rst index 3c1b04674846..2956f8a4b72e 100644 --- a/doc/faq/usage_faq.rst +++ b/doc/faq/usage_faq.rst @@ -370,10 +370,10 @@ renderer for user interfaces is ``Agg`` which uses the `Anti-Grain Geometry`_ C++ library to make a raster (pixel) image of the figure. All of the user interfaces except ``macosx`` can be used with agg rendering, e.g., -``WXAgg``, ``GTKAgg``, ``QT4Agg``, ``TkAgg``. In +``WXAgg``, ``GTKAgg``, ``QT4Agg``, ``QT5Agg``, ``TkAgg``. In addition, some of the user interfaces support other rendering engines. For example, with GTK, you can also select GDK rendering (backend -``GTK``) or Cairo rendering (backend ``GTKCairo``). +``GTK`` deprecated in 2.0) or Cairo rendering (backend ``GTKCairo``). For the rendering engines, one can also distinguish between `vector `_ or `raster @@ -404,7 +404,7 @@ SVG :term:`svg` :term:`vector graphics` -- :term:`svg` ... :term:`GDK` :term:`png` :term:`raster graphics` -- - :term:`jpg` the `Gimp Drawing Kit`_ + :term:`jpg` the `Gimp Drawing Kit`_ Deprecated in 2.0 :term:`tiff` ... ============= ============ ================================================ @@ -421,8 +421,9 @@ GTKAgg Agg rendering to a :term:`GTK` 2.x canvas (requires PyGTK_ and pycairo_ or cairocffi_; Python2 only) GTK3Agg Agg rendering to a :term:`GTK` 3.x canvas (requires PyGObject_ and pycairo_ or cairocffi_) -GTK GDK rendering to a :term:`GTK` 2.x canvas (not recommended) - (requires PyGTK_ and pycairo_ or cairocffi_; Python2 only) +GTK GDK rendering to a :term:`GTK` 2.x canvas (not recommended and d + eprecated in 2.0) (requires PyGTK_ and pycairo_ or cairocffi_; + Python2 only) GTKCairo Cairo rendering to a :term:`GTK` 2.x canvas (requires PyGTK_ and pycairo_ or cairocffi_; Python2 only) GTK3Cairo Cairo rendering to a :term:`GTK` 3.x canvas (requires PyGObject_ @@ -430,7 +431,7 @@ GTK3Cairo Cairo rendering to a :term:`GTK` 3.x canvas (requires PyGObject_ WXAgg Agg rendering to to a :term:`wxWidgets` canvas (requires wxPython_) WX Native :term:`wxWidgets` drawing to a :term:`wxWidgets` Canvas - (not recommended) (requires wxPython_) + (not recommended and deprecated in 2.0) (requires wxPython_) TkAgg Agg rendering to a :term:`Tk` canvas (requires TkInter_) Qt4Agg Agg rendering to a :term:`Qt4` canvas (requires PyQt4_ or ``pyside``) Qt5Agg Agg rendering in a :term:`Qt5` canvas (requires PyQt5_) diff --git a/doc/users/screenshots.rst b/doc/users/screenshots.rst index e73367540d14..acc5bd76e47e 100644 --- a/doc/users/screenshots.rst +++ b/doc/users/screenshots.rst @@ -279,7 +279,7 @@ rendering of strings with the *usetex* option. EEG demo ========= -You can embed matplotlib into pygtk, wx, Tk, FLTK, or Qt applications. +You can embed matplotlib into pygtk, wx, Tk, or Qt applications. Here is a screenshot of an EEG viewer called `pbrain `__. diff --git a/examples/README.txt b/examples/README.txt index 4cd6bafca2c2..45e2c37b9d64 100644 --- a/examples/README.txt +++ b/examples/README.txt @@ -38,6 +38,6 @@ directories found here: * units - working with unit data an custom types in matplotlib * user_interfaces - using matplotlib in a GUI application, e.g., - TkInter, WXPython, pygtk, pyqt or FLTK widgets + TkInter, WXPython, pygtk, pyqt widgets * widgets - Examples using interactive widgets diff --git a/examples/event_handling/test_mouseclicks.py b/examples/event_handling/test_mouseclicks.py index 506ee5b1cd7b..db8499930139 100755 --- a/examples/event_handling/test_mouseclicks.py +++ b/examples/event_handling/test_mouseclicks.py @@ -6,7 +6,6 @@ #matplotlib.use("TkAgg") #matplotlib.use("GTKAgg") #matplotlib.use("Qt4Agg") -#matplotlib.use("CocoaAgg") #matplotlib.use("MacOSX") import matplotlib.pyplot as plt diff --git a/examples/user_interfaces/README.txt b/examples/user_interfaces/README.txt index 768622ecec70..36bff79d0834 100644 --- a/examples/user_interfaces/README.txt +++ b/examples/user_interfaces/README.txt @@ -3,11 +3,9 @@ Embedding matplotlib in graphical user interfaces You can embed matplotlib directly into a user interface application by following the embedding_in_SOMEGUI.py examples here. Currently -matplotlib supports wxpython, pygtk, tkinter, pyqt, fltk and cocoa. +matplotlib supports wxpython, pygtk, tkinter and pyqt4/5. When embedding matplotlib in a GUI, you must use the matplotlib API directly rather than the pylab/pyplot proceedural interface, so take a look at the examples/api directory for some example code working with the API. - - diff --git a/lib/matplotlib/backends/Matplotlib.nib/classes.nib b/lib/matplotlib/backends/Matplotlib.nib/classes.nib deleted file mode 100644 index 5f296f1ea4a3..000000000000 --- a/lib/matplotlib/backends/Matplotlib.nib/classes.nib +++ /dev/null @@ -1,59 +0,0 @@ - - - - - IBClasses - - - CLASS - FirstResponder - LANGUAGE - ObjC - SUPERCLASS - NSObject - - - ACTIONS - - printFigure - id - quit - id - saveFigure - id - - CLASS - MatplotlibController - LANGUAGE - ObjC - OUTLETS - - plotView - PlotView - plotWindow - NSWindow - - SUPERCLASS - NSObject - - - CLASS - PlotView - LANGUAGE - ObjC - SUPERCLASS - NSImageView - - - CLASS - PlotWindow - LANGUAGE - ObjC - SUPERCLASS - NSWindow - - - IBVersion - 1 - - diff --git a/lib/matplotlib/backends/Matplotlib.nib/info.nib b/lib/matplotlib/backends/Matplotlib.nib/info.nib deleted file mode 100644 index 1019096bcbb4..000000000000 --- a/lib/matplotlib/backends/Matplotlib.nib/info.nib +++ /dev/null @@ -1,16 +0,0 @@ - - - - - IBDocumentLocation - 42 396 439 411 0 0 1280 832 - IBFramework Version - 446.1 - IBOpenObjects - - 21 - - IBSystem Version - 8L127 - - diff --git a/lib/matplotlib/backends/Matplotlib.nib/keyedobjects.nib b/lib/matplotlib/backends/Matplotlib.nib/keyedobjects.nib deleted file mode 100644 index 9d6c3065d80d..000000000000 --- a/lib/matplotlib/backends/Matplotlib.nib/keyedobjects.nib +++ /dev/null @@ -1,1225 +0,0 @@ - - - - - $archiver - NSKeyedArchiver - $objects - - $null - - $class - - CF$UID - 97 - - NSAccessibilityConnectors - - CF$UID - 94 - - NSAccessibilityOidsKeys - - CF$UID - 95 - - NSAccessibilityOidsValues - - CF$UID - 96 - - NSClassesKeys - - CF$UID - 77 - - NSClassesValues - - CF$UID - 78 - - NSConnections - - CF$UID - 52 - - NSFontManager - - CF$UID - 0 - - NSFramework - - CF$UID - 6 - - NSNamesKeys - - CF$UID - 72 - - NSNamesValues - - CF$UID - 73 - - NSNextOid - 262 - NSObjectsKeys - - CF$UID - 69 - - NSObjectsValues - - CF$UID - 71 - - NSOidsKeys - - CF$UID - 79 - - NSOidsValues - - CF$UID - 80 - - NSRoot - - CF$UID - 2 - - NSVisibleWindows - - CF$UID - 7 - - - - $class - - CF$UID - 5 - - NSClassName - - CF$UID - 3 - - - - $class - - CF$UID - 4 - - NS.string - NSApplication - - - $classes - - NSMutableString - NSString - NSObject - - $classname - NSMutableString - - - $classes - - NSCustomObject - NSObject - - $classname - NSCustomObject - - - $class - - CF$UID - 4 - - NS.string - IBCocoaFramework - - - $class - - CF$UID - 25 - - NS.objects - - - CF$UID - 8 - - - - - $class - - CF$UID - 51 - - NSMaxSize - - CF$UID - 50 - - NSMinSize - - CF$UID - 49 - - NSScreenRect - - CF$UID - 48 - - NSViewClass - - CF$UID - 12 - - NSWTFlags - 807927808 - NSWindowBacking - 2 - NSWindowClass - - CF$UID - 11 - - NSWindowRect - - CF$UID - 9 - - NSWindowStyleMask - 270 - NSWindowTitle - - CF$UID - 10 - - NSWindowView - - CF$UID - 13 - - - {{50, 189}, {600, 500}} - Matplotlib - PlotWindow - - $class - - CF$UID - 4 - - NS.string - View - - - $class - - CF$UID - 47 - - NSFrame - - CF$UID - 46 - - NSNextResponder - - CF$UID - 0 - - NSSubviews - - CF$UID - 14 - - - - $class - - CF$UID - 45 - - NS.objects - - - CF$UID - 15 - - - CF$UID - 30 - - - CF$UID - 41 - - - - - $class - - CF$UID - 29 - - NSCell - - CF$UID - 27 - - NSClassName - - CF$UID - 16 - - NSDragTypes - - CF$UID - 18 - - NSEditable - - NSEnabled - - NSFrame - - CF$UID - 26 - - NSNextResponder - - CF$UID - 13 - - NSOriginalClassName - - CF$UID - 17 - - NSSuperview - - CF$UID - 13 - - NSvFlags - 274 - - PlotView - NSImageView - - $class - - CF$UID - 25 - - NS.objects - - - CF$UID - 19 - - - CF$UID - 20 - - - CF$UID - 21 - - - CF$UID - 22 - - - CF$UID - 23 - - - CF$UID - 24 - - - - Apple PDF pasteboard type - NeXT Encapsulated PostScript v1.2 pasteboard type - NeXT TIFF v4.0 pasteboard type - NSFilenamesPboardType - Apple PICT pasteboard type - Apple PNG pasteboard type - - $classes - - NSMutableSet - NSSet - NSObject - - $classname - NSMutableSet - - {{7, 52}, {586, 441}} - - $class - - CF$UID - 28 - - NSAlign - 0 - NSAnimates - - NSCellFlags - 130560 - NSCellFlags2 - 33554432 - NSScale - 2 - NSStyle - 2 - - - $classes - - NSImageCell - %NSImageCell - NSCell - NSObject - - $classname - NSImageCell - - - $classes - - NSClassSwapper - NSObject - - $classname - NSClassSwapper - - - $class - - CF$UID - 40 - - NSCell - - CF$UID - 32 - - NSEnabled - - NSFrame - - CF$UID - 31 - - NSNextResponder - - CF$UID - 13 - - NSSuperview - - CF$UID - 13 - - NSvFlags - 289 - - {{486, 20}, {94, 20}} - - $class - - CF$UID - 39 - - NSAlternateContents - - CF$UID - 38 - - NSAlternateImage - - CF$UID - 37 - - NSButtonFlags - -2038021889 - NSButtonFlags2 - 32 - NSCellFlags - 67239424 - NSCellFlags2 - 134348800 - NSContents - - CF$UID - 33 - - NSControlView - - CF$UID - 30 - - NSKeyEquivalent - - CF$UID - 38 - - NSPeriodicDelay - 400 - NSPeriodicInterval - 75 - NSSupport - - CF$UID - 34 - - - Save Figure - - $class - - CF$UID - 36 - - NSName - - CF$UID - 35 - - NSSize - 11 - NSfFlags - 3100 - - LucidaGrande - - $classes - - NSFont - NSObject - - $classname - NSFont - - - $class - - CF$UID - 36 - - NSName - - CF$UID - 35 - - NSSize - 11 - NSfFlags - 16 - - - - $classes - - NSButtonCell - %NSButtonCell - NSActionCell - NSCell - NSObject - - $classname - NSButtonCell - - - $classes - - NSButton - NSControl - NSView - NSResponder - NSObject - - $classname - NSButton - - - $class - - CF$UID - 40 - - NSCell - - CF$UID - 43 - - NSEnabled - - NSFrame - - CF$UID - 42 - - NSNextResponder - - CF$UID - 13 - - NSSuperview - - CF$UID - 13 - - NSvFlags - 292 - - {{20, 20}, {94, 20}} - - $class - - CF$UID - 39 - - NSAlternateContents - - CF$UID - 38 - - NSAlternateImage - - CF$UID - 37 - - NSButtonFlags - -2038021889 - NSButtonFlags2 - 32 - NSCellFlags - 67239424 - NSCellFlags2 - 134348800 - NSContents - - CF$UID - 44 - - NSControlView - - CF$UID - 41 - - NSKeyEquivalent - - CF$UID - 38 - - NSPeriodicDelay - 400 - NSPeriodicInterval - 75 - NSSupport - - CF$UID - 34 - - - Print - - $classes - - NSMutableArray - NSArray - NSObject - - $classname - NSMutableArray - - {{1, 9}, {600, 500}} - - $classes - - NSView - NSResponder - NSObject - - $classname - NSView - - {{0, 0}, {1024, 746}} - {213, 129} - {3.40282e+38, 3.40282e+38} - - $classes - - NSWindowTemplate - NSObject - - $classname - NSWindowTemplate - - - $class - - CF$UID - 45 - - NS.objects - - - CF$UID - 53 - - - CF$UID - 58 - - - CF$UID - 60 - - - CF$UID - 63 - - - CF$UID - 65 - - - CF$UID - 67 - - - - - $class - - CF$UID - 57 - - NSDestination - - CF$UID - 15 - - NSLabel - - CF$UID - 56 - - NSSource - - CF$UID - 54 - - - - $class - - CF$UID - 5 - - NSClassName - - CF$UID - 55 - - - MatplotlibController - plotView - - $classes - - NSNibOutletConnector - NSNibConnector - NSObject - - $classname - NSNibOutletConnector - - - $class - - CF$UID - 57 - - NSDestination - - CF$UID - 8 - - NSLabel - - CF$UID - 59 - - NSSource - - CF$UID - 54 - - - plotWindow - - $class - - CF$UID - 62 - - NSDestination - - CF$UID - 54 - - NSLabel - - CF$UID - 61 - - NSSource - - CF$UID - 30 - - - saveFigure: - - $classes - - NSNibControlConnector - NSNibConnector - NSObject - - $classname - NSNibControlConnector - - - $class - - CF$UID - 57 - - NSDestination - - CF$UID - 54 - - NSLabel - - CF$UID - 64 - - NSSource - - CF$UID - 8 - - - delegate - - $class - - CF$UID - 57 - - NSDestination - - CF$UID - 54 - - NSLabel - - CF$UID - 66 - - NSSource - - CF$UID - 2 - - - delegate - - $class - - CF$UID - 62 - - NSDestination - - CF$UID - 54 - - NSLabel - - CF$UID - 68 - - NSSource - - CF$UID - 41 - - - printFigure: - - $class - - CF$UID - 70 - - NS.objects - - - CF$UID - 41 - - - CF$UID - 54 - - - CF$UID - 13 - - - CF$UID - 30 - - - CF$UID - 8 - - - CF$UID - 15 - - - - - $classes - - NSArray - NSObject - - $classname - NSArray - - - $class - - CF$UID - 70 - - NS.objects - - - CF$UID - 13 - - - CF$UID - 2 - - - CF$UID - 8 - - - CF$UID - 13 - - - CF$UID - 2 - - - CF$UID - 13 - - - - - $class - - CF$UID - 70 - - NS.objects - - - CF$UID - 54 - - - CF$UID - 8 - - - CF$UID - 2 - - - - - $class - - CF$UID - 70 - - NS.objects - - - CF$UID - 74 - - - CF$UID - 75 - - - CF$UID - 76 - - - - MatplotlibController - Window - - $class - - CF$UID - 4 - - NS.string - File's Owner - - - $class - - CF$UID - 70 - - NS.objects - - - CF$UID - 15 - - - - - $class - - CF$UID - 70 - - NS.objects - - - CF$UID - 16 - - - - - $class - - CF$UID - 70 - - NS.objects - - - CF$UID - 63 - - - CF$UID - 54 - - - CF$UID - 60 - - - CF$UID - 30 - - - CF$UID - 67 - - - CF$UID - 8 - - - CF$UID - 53 - - - CF$UID - 41 - - - CF$UID - 13 - - - CF$UID - 65 - - - CF$UID - 15 - - - CF$UID - 58 - - - CF$UID - 2 - - - - - $class - - CF$UID - 70 - - NS.objects - - - CF$UID - 81 - - - CF$UID - 82 - - - CF$UID - 83 - - - CF$UID - 84 - - - CF$UID - 85 - - - CF$UID - 86 - - - CF$UID - 87 - - - CF$UID - 88 - - - CF$UID - 89 - - - CF$UID - 90 - - - CF$UID - 91 - - - CF$UID - 92 - - - CF$UID - 93 - - - - 258 - 248 - 251 - 247 - 261 - 21 - 249 - 260 - 2 - 259 - 246 - 250 - 1 - - $class - - CF$UID - 45 - - NS.objects - - - - $class - - CF$UID - 70 - - NS.objects - - - - $class - - CF$UID - 70 - - NS.objects - - - - $classes - - NSIBObjectData - NSObject - - $classname - NSIBObjectData - - - $top - - IB.objectdata - - CF$UID - 1 - - - $version - 100000 - - diff --git a/lib/matplotlib/backends/backend_cocoaagg.py b/lib/matplotlib/backends/backend_cocoaagg.py deleted file mode 100644 index 3b924fef060b..000000000000 --- a/lib/matplotlib/backends/backend_cocoaagg.py +++ /dev/null @@ -1,306 +0,0 @@ -""" - backend_cocoaagg.py - - A native Cocoa backend via PyObjC in OSX. - - Author: Charles Moad (cmoad@users.sourceforge.net) - - Notes: - - Requires PyObjC (currently testing v1.3.7) - - The Tk backend works nicely on OSX. This code - primarily serves as an example of embedding a - matplotlib rendering context into a cocoa app - using a NSImageView. -""" -from __future__ import (absolute_import, division, print_function, - unicode_literals) - -import six -from six.moves import xrange - -import os, sys - -try: - import objc -except ImportError: - raise ImportError('The CococaAgg backend required PyObjC to be installed!') - -from Foundation import * -from AppKit import * -from PyObjCTools import NibClassBuilder, AppHelper - -from matplotlib import cbook -cbook.warn_deprecated( - '1.3', - message="The CocoaAgg backend is not a fully-functioning backend. " - "It may be removed in matplotlib 1.4.") - -import matplotlib -from matplotlib.figure import Figure -from matplotlib.backend_bases import FigureManagerBase, FigureCanvasBase -from matplotlib.backend_bases import ShowBase - -from .backend_agg import FigureCanvasAgg -from matplotlib._pylab_helpers import Gcf - -mplBundle = NSBundle.bundleWithPath_(os.path.dirname(__file__)) - - -def new_figure_manager(num, *args, **kwargs): - FigureClass = kwargs.pop('FigureClass', Figure) - thisFig = FigureClass( *args, **kwargs ) - return new_figure_manager_given_figure(num, thisFig) - - -def new_figure_manager_given_figure(num, figure): - """ - Create a new figure manager instance for the given figure. - """ - canvas = FigureCanvasCocoaAgg(figure) - return FigureManagerCocoaAgg(canvas, num) - - -## Below is the original show() function: -#def show(): -# for manager in Gcf.get_all_fig_managers(): -# manager.show() -# -## It appears that this backend is unusual in having a separate -## run function invoked for each figure, instead of a single -## mainloop. Presumably there is no blocking at all. -## -## Using the Show class below should cause no difference in -## behavior. - -class Show(ShowBase): - def mainloop(self): - pass - -show = Show() - -def draw_if_interactive(): - if matplotlib.is_interactive(): - figManager = Gcf.get_active() - if figManager is not None: - figManager.show() - -class FigureCanvasCocoaAgg(FigureCanvasAgg): - def draw(self): - FigureCanvasAgg.draw(self) - - def blit(self, bbox): - pass - - def start_event_loop(self,timeout): - FigureCanvasBase.start_event_loop_default(self,timeout) - start_event_loop.__doc__=FigureCanvasBase.start_event_loop_default.__doc__ - - def stop_event_loop(self): - FigureCanvasBase.stop_event_loop_default(self) - stop_event_loop.__doc__=FigureCanvasBase.stop_event_loop_default.__doc__ - - - -NibClassBuilder.extractClasses('Matplotlib.nib', mplBundle) - -class MatplotlibController(NibClassBuilder.AutoBaseClass): - # available outlets: - # NSWindow plotWindow - # PlotView plotView - - def awakeFromNib(self): - # Get a reference to the active canvas - NSApp().setDelegate_(self) - self.app = NSApp() - self.canvas = Gcf.get_active().canvas - self.plotView.canvas = self.canvas - self.canvas.plotView = self.plotView - - self.plotWindow.setAcceptsMouseMovedEvents_(True) - self.plotWindow.makeKeyAndOrderFront_(self) - self.plotWindow.setDelegate_(self)#.plotView) - - self.plotView.setImageFrameStyle_(NSImageFrameGroove) - self.plotView.image_ = NSImage.alloc().initWithSize_((0,0)) - self.plotView.setImage_(self.plotView.image_) - - # Make imageview first responder for key events - self.plotWindow.makeFirstResponder_(self.plotView) - - # Force the first update - self.plotView.windowDidResize_(self) - - def windowDidResize_(self, sender): - self.plotView.windowDidResize_(sender) - - def windowShouldClose_(self, sender): - #NSApplication.sharedApplication().stop_(self) - self.app.stop_(self) - return objc.YES - - def saveFigure_(self, sender): - p = NSSavePanel.savePanel() - if(p.runModal() == NSFileHandlingPanelOKButton): - self.canvas.print_figure(p.filename()) - - def printFigure_(self, sender): - op = NSPrintOperation.printOperationWithView_(self.plotView) - op.runOperation() - -class PlotWindow(NibClassBuilder.AutoBaseClass): - pass - -class PlotView(NibClassBuilder.AutoBaseClass): - def updatePlot(self): - w,h = self.canvas.get_width_height() - - # Remove all previous images - for i in xrange(self.image_.representations().count()): - self.image_.removeRepresentation_(self.image_.representations().objectAtIndex_(i)) - - self.image_.setSize_((w,h)) - - brep = NSBitmapImageRep.alloc().initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bytesPerRow_bitsPerPixel_( - (self.canvas.buffer_rgba(),'','','',''), # Image data - w, # width - h, # height - 8, # bits per pixel - 4, # components per pixel - True, # has alpha? - False, # is planar? - NSCalibratedRGBColorSpace, # color space - w*4, # row bytes - 32) # bits per pixel - - self.image_.addRepresentation_(brep) - self.setNeedsDisplay_(True) - - def windowDidResize_(self, sender): - w,h = self.bounds().size - dpi = self.canvas.figure.dpi - self.canvas.figure.set_size_inches(w / dpi, h / dpi, forward=False) - self.canvas.draw() - self.updatePlot() - - def mouseDown_(self, event): - dblclick = (event.clickCount() == 2) - loc = self.convertPoint_fromView_(event.locationInWindow(), None) - type = event.type() - if (type == NSLeftMouseDown): - button = 1 - else: - print('Unknown mouse event type:', type, file=sys.stderr) - button = -1 - self.canvas.button_press_event(loc.x, loc.y, button, dblclick=dblclick) - self.updatePlot() - - def mouseDragged_(self, event): - loc = self.convertPoint_fromView_(event.locationInWindow(), None) - self.canvas.motion_notify_event(loc.x, loc.y) - self.updatePlot() - - def mouseUp_(self, event): - loc = self.convertPoint_fromView_(event.locationInWindow(), None) - type = event.type() - if (type == NSLeftMouseUp): - button = 1 - else: - print('Unknown mouse event type:', type, file=sys.stderr) - button = -1 - self.canvas.button_release_event(loc.x, loc.y, button) - self.updatePlot() - - def keyDown_(self, event): - self.canvas.key_press_event(event.characters()) - self.updatePlot() - - def keyUp_(self, event): - self.canvas.key_release_event(event.characters()) - self.updatePlot() - -class MPLBootstrap(NSObject): - # Loads the nib containing the PlotWindow and PlotView - def startWithBundle_(self, bundle): - #NSApplicationLoad() - if not bundle.loadNibFile_externalNameTable_withZone_('Matplotlib.nib', {}, None): - print('Unable to load Matplotlib Cocoa UI!', file=sys.stderr) - sys.exit() - -class FigureManagerCocoaAgg(FigureManagerBase): - def __init__(self, canvas, num): - FigureManagerBase.__init__(self, canvas, num) - - try: - WMEnable('Matplotlib') - except: - # MULTIPLE FIGURES ARE BUGGY! - pass # If there are multiple figures we only need to enable once - #self.bootstrap = MPLBootstrap.alloc().init().performSelectorOnMainThread_withObject_waitUntilDone_( - # 'startWithBundle:', - # mplBundle, - # False) - - def show(self): - # Load a new PlotWindow - self.bootstrap = MPLBootstrap.alloc().init().performSelectorOnMainThread_withObject_waitUntilDone_( - 'startWithBundle:', - mplBundle, - False) - NSApplication.sharedApplication().run() - - -#### Everything below taken from PyObjC examples -#### This is a hack to allow python scripts to access -#### the window manager without running pythonw. -def S(*args): - return ''.join(args) - -OSErr = objc._C_SHT -OUTPSN = 'o^{ProcessSerialNumber=LL}' -INPSN = 'n^{ProcessSerialNumber=LL}' -FUNCTIONS=[ - # These two are public API - ( 'GetCurrentProcess', S(OSErr, OUTPSN) ), - ( 'SetFrontProcess', S(OSErr, INPSN) ), - # This is undocumented SPI - ( 'CPSSetProcessName', S(OSErr, INPSN, objc._C_CHARPTR) ), - ( 'CPSEnableForegroundOperation', S(OSErr, INPSN) ), -] -def WMEnable(name='Python'): - if isinstance(name, six.text_type): - name = name.encode('utf8') - mainBundle = NSBundle.mainBundle() - bPath = os.path.split(os.path.split(os.path.split(sys.executable)[0])[0])[0] - if mainBundle.bundlePath() == bPath: - return True - bndl = NSBundle.bundleWithPath_(objc.pathForFramework('/System/Library/Frameworks/ApplicationServices.framework')) - if bndl is None: - print('ApplicationServices missing', file=sys.stderr) - return False - d = {} - objc.loadBundleFunctions(bndl, d, FUNCTIONS) - for (fn, sig) in FUNCTIONS: - if fn not in d: - print('Missing', fn, file=sys.stderr) - return False - err, psn = d['GetCurrentProcess']() - if err: - print('GetCurrentProcess', (err, psn), file=sys.stderr) - return False - err = d['CPSSetProcessName'](psn, name) - if err: - print('CPSSetProcessName', (err, psn), file=sys.stderr) - return False - err = d['CPSEnableForegroundOperation'](psn) - if err: - #print >>sys.stderr, 'CPSEnableForegroundOperation', (err, psn) - return False - err = d['SetFrontProcess'](psn) - if err: - print('SetFrontProcess', (err, psn), file=sys.stderr) - return False - return True - - -FigureCanvas = FigureCanvasCocoaAgg -FigureManager = FigureManagerCocoaAgg diff --git a/lib/matplotlib/backends/backend_gdk.py b/lib/matplotlib/backends/backend_gdk.py index 6afbbd6d2ff4..93e00446beb1 100644 --- a/lib/matplotlib/backends/backend_gdk.py +++ b/lib/matplotlib/backends/backend_gdk.py @@ -26,7 +26,7 @@ def fn_name(): return sys._getframe(1).f_code.co_name from matplotlib._pylab_helpers import Gcf from matplotlib.backend_bases import RendererBase, GraphicsContextBase, \ FigureManagerBase, FigureCanvasBase -from matplotlib.cbook import is_string_like, restrict_dict +from matplotlib.cbook import is_string_like, restrict_dict, warn_deprecated from matplotlib.figure import Figure from matplotlib.mathtext import MathTextParser from matplotlib.transforms import Affine2D @@ -434,7 +434,14 @@ def new_figure_manager_given_figure(num, figure): class FigureCanvasGDK (FigureCanvasBase): def __init__(self, figure): FigureCanvasBase.__init__(self, figure) - + if self.__class__ == matplotlib.backends.backend_gdk.FigureCanvasGDK: + 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. " + "See Matplotlib usage FAQ for" + " more info on backends.", + alternative="Agg") self._renderer_init() def _renderer_init(self): diff --git a/lib/matplotlib/backends/backend_gtk.py b/lib/matplotlib/backends/backend_gtk.py index dca0b882fcb4..83b5c4a5cbac 100644 --- a/lib/matplotlib/backends/backend_gtk.py +++ b/lib/matplotlib/backends/backend_gtk.py @@ -37,6 +37,7 @@ def fn_name(): return sys._getframe(1).f_code.co_name from matplotlib.cbook import is_string_like, is_writable_file_like from matplotlib.figure import Figure from matplotlib.widgets import SubplotTool +from matplotlib.cbook import warn_deprecated from matplotlib import ( cbook, colors as mcolors, lines, markers, rcParams, verbose) @@ -212,6 +213,14 @@ class FigureCanvasGTK (gtk.DrawingArea, FigureCanvasBase): gdk.POINTER_MOTION_HINT_MASK) def __init__(self, figure): + if self.__class__ == matplotlib.backends.backend_gtk.FigureCanvasGTK: + warn_deprecated('2.0', message="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. " + "See Matplotlib usage FAQ for" + " more info on backends.", + alternative="GTKAgg") if _debug: print('FigureCanvasGTK.%s' % fn_name()) FigureCanvasBase.__init__(self, figure) gtk.DrawingArea.__init__(self) diff --git a/lib/matplotlib/backends/backend_wx.py b/lib/matplotlib/backends/backend_wx.py index d710224cce48..697b7f0495c2 100644 --- a/lib/matplotlib/backends/backend_wx.py +++ b/lib/matplotlib/backends/backend_wx.py @@ -35,7 +35,8 @@ from matplotlib.backend_bases import _has_pil from matplotlib._pylab_helpers import Gcf -from matplotlib.cbook import is_string_like, is_writable_file_like +from matplotlib.cbook import (is_string_like, is_writable_file_like, + warn_deprecated) from matplotlib.figure import Figure from matplotlib.path import Path from matplotlib.transforms import Affine2D @@ -188,6 +189,12 @@ def __init__(self, bitmap, dpi): """ Initialise a wxWindows renderer instance. """ + warn_deprecated('2.0', message="The WX backend is " + "deprecated. It's untested " + "and will be removed in Matplotlib 2.2. " + "Use the WXAgg backend instead. " + "See Matplotlib usage FAQ for more info on backends.", + alternative='WXAgg') RendererBase.__init__(self) DEBUG_MSG("__init__()", 1, self) self.width = bitmap.GetWidth() diff --git a/lib/matplotlib/rcsetup.py b/lib/matplotlib/rcsetup.py index dea567921e9b..fb0b60634d9e 100644 --- a/lib/matplotlib/rcsetup.py +++ b/lib/matplotlib/rcsetup.py @@ -37,16 +37,16 @@ from cycler import Cycler, cycler as ccycler # interactive_bk = ['gtk', 'gtkagg', 'gtkcairo', 'qt4agg', -# 'tkagg', 'wx', 'wxagg', 'cocoaagg', 'webagg'] +# 'tkagg', 'wx', 'wxagg', 'webagg'] # The capitalized forms are needed for ipython at present; this may # change for later versions. interactive_bk = ['GTK', 'GTKAgg', 'GTKCairo', 'MacOSX', - 'Qt4Agg', 'Qt5Agg', 'TkAgg', 'WX', 'WXAgg', 'CocoaAgg', + 'Qt4Agg', 'Qt5Agg', 'TkAgg', 'WX', 'WXAgg', 'GTK3Cairo', 'GTK3Agg', 'WebAgg', 'nbAgg'] -non_interactive_bk = ['agg', 'cairo', 'emf', 'gdk', +non_interactive_bk = ['agg', 'cairo', 'gdk', 'pdf', 'pgf', 'ps', 'svg', 'template'] all_backends = interactive_bk + non_interactive_bk diff --git a/lib/matplotlib/tests/test_coding_standards.py b/lib/matplotlib/tests/test_coding_standards.py index a2ae045c8a20..529591fddf18 100644 --- a/lib/matplotlib/tests/test_coding_standards.py +++ b/lib/matplotlib/tests/test_coding_standards.py @@ -221,7 +221,6 @@ def test_pep8_conformance_installed_files(): 'backends/__init__.py', 'backends/backend_agg.py', 'backends/backend_cairo.py', - 'backends/backend_cocoaagg.py', 'backends/backend_gdk.py', 'backends/backend_gtk.py', 'backends/backend_gtk3.py', diff --git a/matplotlibrc.template b/matplotlibrc.template index 333f7c881430..77c812f81c9a 100644 --- a/matplotlibrc.template +++ b/matplotlibrc.template @@ -30,7 +30,7 @@ #### CONFIGURATION BEGINS HERE # The default backend; one of GTK GTKAgg GTKCairo GTK3Agg GTK3Cairo -# CocoaAgg MacOSX Qt4Agg Qt5Agg TkAgg WX WXAgg Agg Cairo GDK PS PDF SVG +# MacOSX Qt4Agg Qt5Agg TkAgg WX WXAgg Agg Cairo GDK PS PDF SVG # Template. # You can also deploy your own backend outside of matplotlib by # referring to the module name (which must be in the PYTHONPATH) as diff --git a/setup.cfg.template b/setup.cfg.template index cae6f678e19f..e64a9248111f 100644 --- a/setup.cfg.template +++ b/setup.cfg.template @@ -33,8 +33,8 @@ #toolkits_tests = auto [gui_support] -# Matplotlib supports multiple GUI toolkits, including Cocoa, -# GTK, Fltk, MacOSX, Qt, Qt4, Tk, and WX. Support for many of +# Matplotlib supports multiple GUI toolkits, including +# GTK, MacOSX, Qt4, Qt5, Tk, and WX. Support for many of # these toolkits requires AGG, the Anti-Grain Geometry library, # which is provided by matplotlib and built by default. # @@ -80,8 +80,8 @@ [rc_options] # User-configurable options # -# Default backend, one of: Agg, Cairo, CocoaAgg, GTK, GTKAgg, GTKCairo, -# FltkAgg, MacOSX, Pdf, Ps, QtAgg, Qt4Agg, SVG, TkAgg, WX, WXAgg. +# Default backend, one of: Agg, Cairo, GTK, GTKAgg, GTKCairo, +# GTK3Agg, GTK3Cairo, MacOSX, Pdf, Ps, Qt4Agg, Qt5Agg, SVG, TkAgg, WX, WXAgg. # # The Agg, Ps, Pdf and SVG backends do not require external # dependencies. Do not choose GTK, GTKAgg, GTKCairo, MacOSX, or TkAgg