Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/matplotlib/backends/backend_macosx.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ class FigureManagerMac(_macosx.FigureManager, FigureManagerBase):
_toolbar2_class = NavigationToolbar2Mac

def __init__(self, canvas, num):
self._shown = False
_macosx.FigureManager.__init__(self, canvas)
icon_path = str(cbook._get_data_path('images/matplotlib.pdf'))
_macosx.FigureManager.set_icon(icon_path)
Expand All @@ -154,6 +155,13 @@ def close(self):
Gcf.destroy(self)
self.canvas.flush_events()

def show(self):
if not self._shown:
self._show()
self._shown = True
if mpl.rcParams["figure.raise_window"]:
self._raise()


@_Backend.export
class _BackendMac(_Backend):
Expand Down
15 changes: 12 additions & 3 deletions src/_macosx.m
Original file line number Diff line number Diff line change
Expand Up @@ -586,9 +586,15 @@ static CGFloat _get_device_scale(CGContextRef cr)
}

static PyObject*
FigureManager_show(FigureManager* self)
FigureManager__show(FigureManager* self)
{
[self->window makeKeyAndOrderFront: nil];
Py_RETURN_NONE;
}

static PyObject*
FigureManager__raise(FigureManager* self)
{
[self->window orderFrontRegardless];
Py_RETURN_NONE;
}
Expand Down Expand Up @@ -695,8 +701,11 @@ static CGFloat _get_device_scale(CGContextRef cr)
.tp_new = (newfunc)FigureManager_new,
.tp_doc = "A FigureManager object wraps a Cocoa NSWindow object.",
.tp_methods = (PyMethodDef[]){ // All docstrings are inherited.
{"show",
(PyCFunction)FigureManager_show,
{"_show",
(PyCFunction)FigureManager__show,
METH_NOARGS},
{"_raise",
(PyCFunction)FigureManager__raise,
METH_NOARGS},
{"destroy",
(PyCFunction)FigureManager_destroy,
Expand Down