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 0e2935e

Browse filesBrowse files
committed
Remove custom backend_nbagg.show(), putting logic in manager show.
The _Backend class machinery can autogenerate a backend_module.show() function, which (in short) calls manager.show() on all managers and then calls the optionally-provided mainloop() function. backend_nbagg currently completely bypasses this autogeneration because it wants to additionally fiddle with callbacks and Gcf (it doesn't need any mainloop()), but that logic can just as well go to FigureManagerNbAgg.show() instead. This way it benefits from the default-generated show; moreover, it seems a bit strange that figures shown with manager.show() (instead of plt.show()) do indeed get displayed, but just don't have their callbacks/Gcf-ness adjusted. This is also related to the move towards putting show()-generating information on the canvas class for inheritability.
1 parent 037fcca commit 0e2935e
Copy full SHA for 0e2935e

File tree

Expand file treeCollapse file tree

1 file changed

+9
-24
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+9
-24
lines changed

‎lib/matplotlib/backends/backend_nbagg.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_nbagg.py
+9-24Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,15 @@ def show(self):
9696
else:
9797
self.canvas.draw_idle()
9898
self._shown = True
99+
# plt.figure adds an event which makes the figure in focus the active
100+
# one. Disable this behaviour, as it results in figures being put as
101+
# the active figure after they have been shown, even in non-interactive
102+
# mode.
103+
if hasattr(self, '_cidgcf'):
104+
self.canvas.mpl_disconnect(self._cidgcf)
105+
if not is_interactive():
106+
from matplotlib._pylab_helpers import Gcf
107+
Gcf.figs.pop(self.num, None)
99108

100109
def reshow(self):
101110
"""
@@ -232,27 +241,3 @@ def on_message(self, message):
232241
class _BackendNbAgg(_Backend):
233242
FigureCanvas = FigureCanvasNbAgg
234243
FigureManager = FigureManagerNbAgg
235-
236-
@staticmethod
237-
def show(block=None):
238-
## TODO: something to do when keyword block==False ?
239-
from matplotlib._pylab_helpers import Gcf
240-
241-
managers = Gcf.get_all_fig_managers()
242-
if not managers:
243-
return
244-
245-
interactive = is_interactive()
246-
247-
for manager in managers:
248-
manager.show()
249-
250-
# plt.figure adds an event which makes the figure in focus the
251-
# active one. Disable this behaviour, as it results in
252-
# figures being put as the active figure after they have been
253-
# shown, even in non-interactive mode.
254-
if hasattr(manager, '_cidgcf'):
255-
manager.canvas.mpl_disconnect(manager._cidgcf)
256-
257-
if not interactive:
258-
Gcf.figs.pop(manager.num, None)

0 commit comments

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