|
From: <md...@us...> - 2010-08-11 03:24:06
|
Revision: 8625
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8625&view=rev
Author: mdehoon
Date: 2010-08-11 03:23:59 +0000 (Wed, 11 Aug 2010)
Log Message:
-----------
The MacOS module will disappear in Python 3. Implement the WMAvailable()
check in the C code in src/_macosx.m, so we won't rely on the MacOS module.
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/backends/backend_macosx.py
trunk/matplotlib/src/_macosx.m
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_macosx.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_macosx.py 2010-08-05 17:04:14 UTC (rev 8624)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_macosx.py 2010-08-11 03:23:59 UTC (rev 8625)
@@ -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.get_main_display_id():
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: trunk/matplotlib/src/_macosx.m
===================================================================
--- trunk/matplotlib/src/_macosx.m 2010-08-05 17:04:14 UTC (rev 8624)
+++ trunk/matplotlib/src/_macosx.m 2010-08-11 03:23:59 UTC (rev 8625)
@@ -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,31 @@
}
@end
+
+static PyObject*
+show(PyObject* self)
+{
+ if(nwin > 0) [NSApp run];
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject*
+get_main_display_id(PyObject* self)
+{
+ CGDirectDisplayID display = CGMainDisplayID();
+ if (display == 0) {
+ PyErr_SetString(PyExc_RuntimeError, "Failed to obtain the display ID of the main display");
+ return NULL;
+ }
+ return PyInt_FromLong(display);
+}
+
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 +5165,17 @@
METH_VARARGS,
"Sets the active cursor."
},
+ {"get_main_display_id",
+ (PyCFunction)get_main_display_id,
+ METH_NOARGS,
+ "Returns the display ID of the main display. 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.
|