Revision: 8886 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8886&view=rev Author: mdehoon Date: 2011-01-05 13:31:24 +0000 (Wed, 05 Jan 2011)
Log Message: ----------- Replace MacOS.WMAvailable, as the MacOS module is not available with 64-bit Pythons, and deprecated for Python 3. Modified Paths: -------------- branches/v1_0_maint/lib/matplotlib/backends/backend_macosx.py branches/v1_0_maint/src/_macosx.m Modified: branches/v1_0_maint/lib/matplotlib/backends/backend_macosx.py =================================================================== --- branches/v1_0_maint/lib/matplotlib/backends/backend_macosx.py 2011-01-04 22:43:44 UTC (rev 8885) +++ branches/v1_0_maint/lib/matplotlib/backends/backend_macosx.py 2011-01-05 13:31:24 UTC (rev 8886) @@ -2,7 +2,6 @@ import os import numpy -import MacOS from matplotlib._pylab_helpers import Gcf from matplotlib.backend_bases import RendererBase, GraphicsContextBase,\ @@ -229,7 +228,7 @@ """ Create a new figure manager instance """ - if not MacOS.WMAvailable(): + if not _macosx.verify_main_display(): import warnings warnings.warn("Python is not installed as a framework. The MacOSX backend may not work correctly if Python is not installed as a framework. Please see the Python documentation for more information on installing Python as a framework on Mac OS X") FigureClass = kwargs.pop('FigureClass', Figure) Modified: branches/v1_0_maint/src/_macosx.m =================================================================== --- branches/v1_0_maint/src/_macosx.m 2011-01-04 22:43:44 UTC (rev 8885) +++ branches/v1_0_maint/src/_macosx.m 2011-01-05 13:31:24 UTC (rev 8886) @@ -4399,16 +4399,6 @@ return Py_None; } -static char show__doc__[] = "Show all the figures and enter the main loop.\nThis function does not return until all Matplotlib windows are closed,\nand is normally not needed in interactive sessions."; - -static PyObject* -show(PyObject* self) -{ - if(nwin > 0) [NSApp run]; - Py_INCREF(Py_None); - return Py_None; -} - @implementation Window - (Window*)initWithContentRect:(NSRect)rect styleMask:(unsigned int)mask backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation withManager: (PyObject*)theManager { @@ -5139,11 +5129,32 @@ } @end + +static PyObject* +show(PyObject* self) +{ + if(nwin > 0) [NSApp run]; + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject* +verify_main_display(PyObject* self) +{ + CGDirectDisplayID display = CGMainDisplayID(); + if (display == 0) { + PyErr_SetString(PyExc_RuntimeError, "Failed to obtain the display ID of the main display"); + return NULL; + } + Py_INCREF(Py_True); + return Py_True; +} + static struct PyMethodDef methods[] = { {"show", (PyCFunction)show, METH_NOARGS, - show__doc__ + "Show all the figures and enter the main loop.\nThis function does not return until all Matplotlib windows are closed,\nand is normally not needed in interactive sessions." }, {"choose_save_file", (PyCFunction)choose_save_file, @@ -5155,11 +5166,17 @@ METH_VARARGS, "Sets the active cursor." }, + {"verify_main_display", + (PyCFunction)verify_main_display, + METH_NOARGS, + "Verifies if the main display can be found. This function fails if Python is not built as a framework." + }, {NULL, NULL, 0, NULL}/* sentinel */ }; void init_macosx(void) { PyObject *m; + import_array(); if (PyType_Ready(&GraphicsContextType) < 0) return; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Learn how Oracle Real Application Clusters (RAC) One Node allows customers to consolidate database storage, standardize their database environment, and, should the need arise, upgrade to a full multi-node Oracle RAC database without downtime or disruption http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ Matplotlib-checkins mailing list Matplotlib-checkins@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins