Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c44b4c2

Browse filesBrowse files
author
Michiel de Hoon
committed
Reintroduce the verify_main_display function to check during runtime if Python was installed as a framework
1 parent 6586369 commit c44b4c2
Copy full SHA for c44b4c2

2 files changed

+25Lines changed: 25 additions & 0 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/matplotlib/backends/backend_macosx.py‎

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_macosx.py
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@
2323
import matplotlib
2424
from matplotlib.backends import _macosx
2525

26+
if not _macosx.verify_main_display():
27+
import warnings
28+
warnings.warn("Python is not installed as a framework. The MacOSX "
29+
"backend may not work correctly if Python is not "
30+
"installed as a framework. Please see the Python "
31+
"documentation for more information on installing "
32+
"Python as a framework on Mac OS X.")
33+
2634

2735
class Show(ShowBase):
2836
def mainloop(self):
Collapse file

‎src/_macosx.m‎

Copy file name to clipboardExpand all lines: src/_macosx.m
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6208,7 +6208,24 @@ static void timer_callback(CFRunLoopTimerRef timer, void* info)
62086208
Timer_new, /* tp_new */
62096209
};
62106210

6211+
6212+
static PyObject*
6213+
verify_main_display(PyObject* self)
6214+
{
6215+
PyObject* result;
6216+
CGDirectDisplayID display = CGMainDisplayID();
6217+
if (display == 0) result = Py_False;
6218+
else result = Py_True;
6219+
Py_INCREF(result);
6220+
return result;
6221+
}
6222+
62116223
static struct PyMethodDef methods[] = {
6224+
{"verify_main_display",
6225+
(PyCFunction)verify_main_display,
6226+
METH_NOARGS,
6227+
"Verifies if the main display can be found. This function returns False if Python is not built as a framework."
6228+
},
62126229
{"show",
62136230
(PyCFunction)show,
62146231
METH_NOARGS,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.